Salesforce JavaScript Developer I Practice Exams
Last updated on Nov 16,2026- Exam Code: JavaScript Developer I
- Exam Name: Salesforce Certified JavaScript Developer I
- Certification Provider: Salesforce
- Latest update: Nov 16,2026
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); };}
Refer to the code below:
const addBy =?
const addByEight =addBy(8);
const sum = addBYEight(50);
Which two functions can replace line 01 and return 58 to sum? Choose 2 answers
- A . const addBy = function(num1){
return function(num2){
return num1 + num2;
} - B . const addBy = function(num1){
return num1 + num2;
} - C . const addBy = (num1) => num1 + num2 ;
- D . const addBY = (num1) => (num2) => num1 + num2;
A developer is wondering whether to use, Promise.then or Promise.catch, especially when a Promise throws an error?
Which two promises are rejected? Which 2 are correct?
- A . Promise.reject(‘cool errorhere’).then(error => console.error(error));
- B . Promise.reject(‘cool error here’).catch(error => console.error(error));
- C . New Promise((resolve, reject) => (throw ‘cool error here’}).catch(error =>console.error(error)) ;
- D . New Promise(() => (throw ‘cool error here’}).then(null, error => console.error(error)));
A developer creates a genericfunction to log custom messages in the console. To do this, the function below is implemented.
01 function logStatus(status){
02 console./*Answer goes here*/{‘Item status is: %s’, status};
03 }
Which three console logging methods allow the use of string substitution in line 02?
- A . Assert
- B . Log
- C . Message
- D . Info
- E . Error
Refer to the following code:

What is the value of output on line 11?
- A . [1, 2]
- B . [‘’foo’’, ‘’bar’’]
- C . [‘’foo’’:1, ‘’bar’’:2’’]
- D . An error will occur due to the incorrect usage of the for…of statement on line 07.
Which statement parses successfully?
- A . JSON. parse (""foo"’);
- B . JSON.parse (""foo’");
- C . JSON.parse ("foo");
- D . JSON.parse ("foo");
In the browser, the window object is often used to assign variables that require the broadest scope in an application Node.js application does not have access to the window object by default.
Which two methods areused to address this? Choose 2 answers
- A . Use the document object instead of the window object.
- B . Assign variables to the global object.
- C . Create a new window object in the root file.
- D . Assign variables to module.exports and require them as needed.
Given the following code:

What will be the first four numbers logged?
- A . 0012
- B . 0112
- C . 0122
- D . 0123
Refer to the code below:
Let str = ‘javascript’;
Str[0] = ‘J’;
Str[4] = ’S’;
After changing the string indexvalues, the value of str is ‘javascript’.
What is the reason for this value:
- A . Non-primitive values are mutable.
- B . Non-primitive values are immutable.
- C . Primitive values are mutable.
- D . Primitive values are immutable.
Refer to the code below:
Let str = ‘javascript’;
Str[0] = ‘J’;
Str[4] = ’S’;
After changing the string indexvalues, the value of str is ‘javascript’.
What is the reason for this value:
- A . Non-primitive values are mutable.
- B . Non-primitive values are immutable.
- C . Primitive values are mutable.
- D . Primitive values are immutable.