Pre-Summer Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: validbest

Pass the Salesforce Developer JavaScript-Developer-I Questions and answers with ValidTests

Exam JavaScript-Developer-I All Questions
Exam JavaScript-Developer-I Premium Access

View all detail and faqs for the JavaScript-Developer-I exam

Viewing page 2 out of 5 pages
Viewing questions 11-20 out of questions
Questions # 11:

Refer to the code below:

Question # 11

What is the output of this function when called with an empty array?

Options:

A.

Return 0

B.

Return 5

C.

Return NaN

D.

Return Infinity

Expert Solution
Questions # 12:

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 theserver

● 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?

Options:

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); }};

C.

try{ws.connect(( ) => {console.log(‘connected to client’); });} catch(error) { console.log(‘ERROR’ ,error); };}

Expert Solution
Questions # 13:

Referto the following code:

<html lang=”en”>

<body>

</body>

<script>

function displayMessage(ev) {

ev.stopPropagation();

console.log(‘Inner message.’);

}

const elem =document.getElementById(‘myButton’);

elem.addEventListener(‘click’ , displayMessage);

</script>

</html>

What will the console show when the button is clicked?

Options:

A.

Outer message

B.

Outer messageInner message

C.

Inner messageOuter message

D.

Inner message

Expert Solution
Questions # 14:

Refer to the following code:

Question # 14

What is the output of line 11?

Options:

A.

[1,2]

B.

["bar", "foo"]

C.

["foo:1", "bar:2"]

D.

["foo", "bar"]

Expert Solution
Questions # 15:

A developer implements and calls the following code whenan application state change occurs:

Const onStateChange =innerPageState) => {

window.history.pushState(newPageState, ‘ ’, null);

}

If the back button is clicked after this method is executed, what can a developer expect?

Options:

A.

A navigate event is fired with astate property that details the previous application state.

B.

The page isnavigated away from and the previous page in the browser’s history is loaded.

C.

The page reloads and all Javascript is reinitialized.

D.

A popstate event is fired with a state property that details the application’s last state.

Expert Solution
Questions # 16:

Which statement phrases successfully?

Options:

A.

JSON.parse ( ‘ foo ’ );

B.

JSON.parse ( “ foo ” );

C.

JSON.parse( “ ‘ foo ’ ” );

D.

JSON.parse(‘ “ foo ” ’);

Expert Solution
Questions # 17:

A developer is working on anecommerce website where the delivery date is dynamically

calculated based on the current day. The code line below is responsible for this calculation.

Const deliveryDate = new Date ();

Due to changes in the business requirements, the delivery date must nowbe today’s

date + 9 days.

Which code meets thisnew requirement?

Options:

A.

deliveryDate.setDate(( new Date ( )).getDate () +9);

B.

deliveryDate.setDate( Date.current () + 9);

C.

deliveryDate.date = new Date(+9) ;

D.

deliveryDate.date = Date.current () + 9;

Expert Solution
Questions # 18:

Given the JavaScript below:

01 function filterDOM (searchString) {

02 constparsedSearchString = searchString && searchString.toLowerCase() ;

03 document.quesrySelectorAll(‘ .account’ ) . forEach(account => (

04 const accountName = account.innerHTML.toLOwerCase();

05 account. Style.display = accountName.includes(parsedSearchString) ? /*Insert

code*/;

06 )};

07 }

Which code should replace the placeholder comment on line 05 to hide accounts that do

not match thesearch string?

Options:

A.

‘ name ’ : ‘ block ’

B.

‘ Block ’ : ‘ none ’

C.

‘ visible ’ : ‘ hidden ’

D.

‘ hidden ’ : ‘ visible ’

Expert Solution
Questions # 19:

A developer needs todebug a Node.js web server because a runtime error keeps occurring at one of the endpoints.

The developer wants to test the endpoint on a local machine and make the request against a local server to look at the behavior. In the source code, the server, jsfile will start the server. the developer wants to debug the Node.js server only using the terminal.

Which command can the developer use to open the CLI debugger in their current terminal window?

Options:

A.

node -i server.js

B.

node inspect server,js

C.

node server,js inspect

D.

node start inspect server,js

Expert Solution
Questions # 20:

Refer to the following array:

Let arr1 = [ 1,2, 3, 4, 5 ];

Question # 20

Which two lines of code result in a second array, arr2 being created such that arr2 is not

a reference to arr1?

Options:

A.

Let arr2 = arr1.slice(0, 5);

B.

Let arr2 = Array.from(arr1);

C.

Let arr2 = arr1;

D.

Let arr2 = arr1.sort();

Expert Solution
Viewing page 2 out of 5 pages
Viewing questions 11-20 out of questions