Practice Free Salesforce Certified JavaScript Developer Exam Online Questions
A developer has an ErrorHandler module that contains multiple functions.
What kind of export should be leveraged so that multiple functions can be used?
- A . all
- B . named
- C . multi
- D . default
The developer wants to test the array shown:
const arr = Array(5).fill(0)
Which two tests are the most accurate for this array? Choose 2 answers:
- A . console.assert( arr.length === 5 );
- B . arr.forEach(elem => console.assert(elem === 0)) ;
- C . console.assert(arr[0] === 0 && arr[ arr.length] === 0);
- D . console.assert (arr.length >0);
Refer to code below:
console.log(0);
setTimeout(() => (
console.log(1);
});
console.log(2);
setTimeout(() => {
console.log(3);
), 0);
console.log(4);
In which sequence will the numbers be logged?
- A . 01234
- B . 02431
- C . 02413
- D . 13024
Universal Containers recently launched its new landing page to host a crowd-funding campaign. The page uses an external library to display some third-party ads.
Once the page is fully loaded, it creates more than 50 new HTML items placed randomly inside the DOM, like the one in the code below:
![]()
All the elements includes the same ad-library-item class, They are hidden by default, and they are randomly displayed while the user navigates through the page.
- A . Use the DOM inspector to prevent the load event to be fired.
- B . Use the browser to execute a script that removes all the element containing the class ad-library-item.
- C . Use the DOM inspector to remove all the elements containing the class ad-library-item.
- D . Use the browser console to execute a script that prevents the load event to be fired.
Works in both the browser and Node.js.
Which meet the requirements?
- A . assert (number % 2 === 0);
- B . console.error(number % 2 === 0);
- C . console.debug(number % 2 === 0);
- D . console.assert(number % 2 === 0);
A developer at Universal Containers creates a new landing page based on HTML, CSS, and JavaScript TO ensure that visitors have a good experience, a script named personaliseContext needs to be executed when the webpage is fully loaded (HTML content and all related files), in order to do some custom initialization.
Which statement should be used to call personalizeWebsiteContent based on the above business requirement?
- A . document.addEventListener(‘’onDOMContextLoaded’, personalizeWebsiteContext);
- B . window.addEventListener(‘load’,personalizeWebsiteContext);
- C . window.addEventListener(‘onload’, personalizeWebsiteContext);
- D . Document.addEventListener(‘‘’DOMContextLoaded’, personalizeWebsiteContext);
Given the JavaScript below:

Which code should replace the placeholder comment on line 05 to highlight accounts that match the search string’
- A . ‘yellow’: null
- B . null: ‘yellow’
- C . ‘none1: "yellow’
- D . ‘yellow: ‘none’
A developer creates a class that represents a blog post based on the requirement that a Post should have a body author and view count.
The Code shown Below:
Class Post{
// Insert code here This.body =body This.author = author; this.viewCount = viewCount;
}
}
Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instanceof a Post with the three attributes correctly populated?
- A . super (body, author, viewCount) {
- B . Function Post (body, author, viewCount) {
- C . constructor (body, author, viewCount) {
- D . constructor () {
A developer is setting up a new Node.js server with a client library that is built using events and callbacks.
The library:
● Will establish a web socket connection and handle receipt of messages to the server
● Will be imported with require, and made available with a variable called we.
The developer also wants to add error logging if a connection fails.
Given this info, which code segment shows the correct way to set up a client with two events that listen at execution time?
- A . ws.connect (( ) => {console.log(‘connected to client’); }).catch((error) => { console.log(‘ERROR’, error); }};
- B . ws.on (‘connect’, () => {console.log(‘connected to client’); ws.on(‘error’, (error) => { console.log(‘ERROR’,error); });});
- C . ws.on (‘connect’, () => { console.log(‘connected to client’); }}; ws.on(‘error’, (error) => { console.log(‘ERROR’, error); }};
- D . try{ws.connect (( ) => {console.log(‘connected to client’); });} catch(error) { console.log(‘ERROR’,error); };}
GIven a value, which three options can a developer use to detect if thevalue is NaN? Choose 3 answers
- A . value == NaN
- B . Object.is(value, NaN)
- C . value === Number.NaN
- D . value ! == value
- E . Number.isNaN(value)
