View all detail and faqs for the JavaScript-Developer-I exam
Refer to the code below:

What is the output of this function when called with an empty array?
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?
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?
Refer to the following code:

What is the output of line 11?
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?
Which statement phrases successfully?
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?
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?
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?
Refer to the following array:
Let arr1 = [ 1,2, 3, 4, 5 ];

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