Javascript Developer I - 5
Javascript Developer I - 5
Get the Full JavaScript-Developer-I dumps in VCE and PDF From SurePassExam
https://www.surepassexam.com/JavaScript-Developer-I-exam-dumps.html (219 New Questions)
Salesforce
Exam Questions JavaScript-Developer-I
Salesforce Certified JavaScript Developer I
NEW QUESTION 1
Refer to the code below:
<html lang=”en”>
<table onclick=”console.log(Table log’);”>
<tr id=”row1”>
<td>Click me!</td>
</tr>
<table>
<script>
function printMessage(event) { console.log(‘Row log’);
}
Let elem = document.getElementById(‘row1’); elem.addEventListener(‘click’, printMessage, false);
</script>
</html>
Which code change should be made for the console to log only Rowlog when ‘Click me! ’ is clicked?
Answer: B
NEW QUESTION 2
Refer to the code snippet:
A developer writes this code to return a message to userattempting to register a new username. If the username is available, variable.
What is the return value of msg hen getAvailabilityMessage (“newUserName” ) is executed and getAvailability(“newUserName”) returns false?
A. “Username available”
B. “newUserName”
C. “Msg is not defined”
D. undefined
Answer: D
NEW QUESTION 3
A developer receives a comment from the Tech Lead that the code given below has error:
const monthName = ‘July’; const year = 2019;
if(year === 2019) { monthName = ‘June’;
}
Which line edit should be made to make this code run?
Answer: A
NEW QUESTION 4
Refer to the code below:
A. Undefined
B. ‘ new york ’
C. ‘ New York ’
D. An error
Answer: B
NEW QUESTION 5
Refer to the code below: Let str = ‘javascript’; Str[0] = ‘J’;
Str[4] = ’S’;
After changing the string index values, the value of str is ‘javascript’. What is the reason for this value:
Answer: D
NEW QUESTION 6
A developer has the following array of student test grades: Let arr = [ 7, 8, 5, 8, 9 ];
The Teacher wants to double each score and then see an array of the students who scored more than 15 points.
How should thedeveloper implement the request?
A. Let arr1 = arr.filter(( val) => ( return val > 15 )) .map (( num) => ( return num *2 ))
B. Let arr1 = arr.mapBy (( num) => ( return num *2 )) .filterBy (( val ) => return val > 15 )) ;
C. Let arr1 = arr.map((num) => num*2). Filter (( val) => val > 15);
D. Let arr1 = arr.map((num) => ( num *2)).filterBy((val) => ( val >15 ));
Answer: C
NEW QUESTION 7
A developer creates an object where its properties should be immutable and prevent properties from being added or modified.
Which method shouldbe used to execute this business requirement ?
A. Object.const()
B. Object.eval()
C. Object.lock()
D. Object.freeze()
Answer: D
NEW QUESTION 8
A developer is creating a simple webpage with a button. When a userclicks this button for the first time, a message is displayed.
The developer wrote the JavaScript code below, but something is missing. The message gets displayed every time a user clicks the button, instead of just the first
time.
Which two code lines make this code work as required? Choose 2 answers
Answer: CD
NEW QUESTION 9
A class was written to represent items for purchase in an online store, and a second class Representing items that are on sale at a discounted price. THe
constructor sets the name to the first value passed in. The pseudocode is below:
There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem.
Answer: B
NEW QUESTION 10
Refer to code below:
Function muFunction(reassign){
Let x = 1;
var y = 1;
if( reassign ) {
Let x= 2;
Var y = 2;
console.log(x);
console.log(y);}
console.log(x);
console.log(y);}
What isdisplayed when myFunction(true) is called?
A. 2 2 1 1
B. 2 2 undefined undefined
C. 2 2 1 2
D. 2 2 2 2
Answer: C
NEW QUESTION 10
Which three browser specific APIs are available for developers to persist data between page loads ? Choose 3 answers
A. IIFEs
B. indexedDB
C. Global variables
D. Cookies
E. localStorage.
Answer: ABE
NEW QUESTION 13
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 aweb 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.
B.
C.
D.
Answer: C
NEW QUESTION 14
A Developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the sum of the first three number in the array, The test
passes:
A different developer made changes to the behavior of sum3 to instead sum all of the numbers present in the array. The test passes:
Which two results occur when running the test on the updated sum3 function ? Choose 2 answers
Answer: AD
NEW QUESTION 19
A developer needs to test this function:
01const sum3 = (arr) => (
02if (!arr.length) return 0,
03if (arr.length === 1) return arr[0],
04if (arr.length === 2) return arr[0]+ arr[1],
05 return arr[0] + arr[1] + arr[2],
06 );
Which two assert statements are valid tests for the function? Choose 2 answers
Answer: AC
NEW QUESTION 20
A developer wrote the following codeto test a sum3 function that takes in an array of numbers and returns the sum of the first three numbers in the array, and the
test passes.
A different developer made changes to the behavior of sum3 to instead sum only the first two numbers present in thearray.
Which two results occur when running this test on the updated sum3 function? Choose 2 answers
Answer: BD
NEW QUESTION 24
Refer to the HTML below:
<div id=”main”>
<ul>
<li>Leo</li>
<li>Tony</li>
<li>Tiger</li>
</ul>
</div>
Which JavaScript statementresults in changing “ Tony” to “Mr. T.”?
A. document.querySelectorAll(‘$main $TONY’).innerHTML = ’ M
B. ’;
C. document.querySelector(‘$main li:second-child’).innerHTML = ’ M
D. ’;
E. document.querySelector(‘$main li.Tony’).innerHTML = ’ M
F. ’;
G. document.querySelector(‘$main li:nth-child(2)’),innerHTML = ’ M
H. ’;
Answer: D
NEW QUESTION 27
Refer to the code below:
1 let car1 = new promise((_, reject) =>
2 setTimeout(reject, 2000, “Car 1 crashed in”));
3 let car2 = new Promise(resolve => setTimeout(resolve, 1500, “Car 2 completed”));
4 let car3 = new Promise(resolve => setTimeout (resolve, 3000, “Car 3 Completed”));
5 Promise.race([car1, car2, car3]) 06 .then(value => (
07 let result = $(value) the race. `; 08 ))
9 catch( arr => (
10 console.log(“Race is cancelled.”, err); 11 ));
What is the value of result when Promise.race executes?
Answer: C
NEW QUESTION 30
Given the following code: Let x =null; console.log(typeof x);
What is the output of the line 02?
A. “Null”
B. “X”
C. “Object”
D. “undefined”
Answer: C
NEW QUESTION 33
Referto the code below: Const pi = 3.1415326, What is the data type of pi?
A. Double
B. Number
C. Decimal
D. Float
Answer: B
NEW QUESTION 34
A developer wants to iterate through an array of objects and count the objects and count the objects whose property value, name, starts with the letter N.
Const arrObj = [{“name” : “Zach”} , {“name” : “Kate”},{“name” : “Alise”},{“name” : “Bob”},{“name” : “Natham”},{“name” : “nathaniel”}
Refer to the code snippet below: 01 arrObj.reduce(( acc, curr) => { 02 //missing line 02
2 //missing line 03
04 ).0);
Which missing lines 02 and 03 return the correct count?
A. Mastered
B. Not Mastered
Answer: A
Explanation:
Explanation
NEW QUESTION 37
Which code statement correctly retrieves and returns an object from localStorage?
Answer: C
NEW QUESTION 39
Refer to the code below:
Answer: A
NEW QUESTION 41
A developer wrote the following code: 01 let X = object.value;
02
3 try {
4 handleObjectValue(X); 05 } catch (error) {
6 handleError(error);
7}
The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs.
How can the developer change the code to ensure thisbehavior?
Answer: D
NEW QUESTION 43
A developer writers the code below to calculate the factorial of a given number.
A. 6
B. -Infinity
C. RuntimeError
Answer: D
Explanation:
NEW QUESTION 47
Given the code below: Setcurrent URL ();
console.log(‘The current URL is: ‘ +url ); function setCurrentUrl() {
Url = window.location.href:
What happens when the code executes?
A. The url variable has local scope and line 02 throws an error.
B. The url variable has global scope and line 02 executes correctly.
C. The url variable has global scope and line 02 throws an error.
D. The url variable has local scope and line 02 executes correctly.
Answer: B
NEW QUESTION 48
developer publishes a new version of a package with new features that do not break backward compatibility. The previous version number was 1.1.3.
Following semantic versioning format, what should the new package version number be?
A. 2.0.0
B. 1.2.3
C. 1.1.4
D. 1.2.0
Answer: D
NEW QUESTION 50
Refer to the code below:
Which two statements correctly execute the runParallel () function? Choose 2 answers
Answer: BD
NEW QUESTION 52
Given the following code: Let x =(‘15’ + 10)*2;
What is the value of a?
A. 3020
B. 1520
C. 50
D. 35
Answer: A
NEW QUESTION 53
Refer to following code block:
Let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,];
Let output =0;
For (let num of array){ if (output >0){
Break;
}
if(num % 2 == 0){
Continue;
}
Output +=num;
What is the value of output after the code executes?
A. 16
B. 36
C. 11
D. 25
Answer: A
NEW QUESTION 54
Refer to the code below? LetsearchString = ‘ look for this ’;
Which two options remove the whitespace from the beginning of searchString? Choose 2 answers
A. searchString.trimEnd();
B. searchString.trimStart();
C. trimStart(searchString);
D. searchString.replace(/*\s\s*/, ‘’);
Answer: BD
NEW QUESTION 55
Refer to the following object:
A. cat.fullName
B. cat.fullName()
C. cat.get.fullName
D. cat.function.fullName()
Answer: A
NEW QUESTION 59
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.
Answer: B
NEW QUESTION 62
Refer to the code below: function changeValue(param) { Param =5;
}
Let a =10;
Let b =5; changeValue(b);
Const result = a+ “ - ”+ b;
What is the value of result when code executes?
A. 10 -10
B. 5 -5
C. 5 - 10
D. 10 - 5
Answer: A
NEW QUESTION 67
Refer to the following code:
A. [1,2]
B. [“bar”,”foo”]
C. [“foo”,”bar”]
D. [“foo:1”,”bar:2”]
Answer: C
NEW QUESTION 69
Refer to the code below:
Answer: B
Explanation:
NEW QUESTION 73
Refer to the code snippet below:
Let array = [1, 2, 3, 4,4, 5, 4, 4];
For (let i =0; i < array.length; i++){ if (array[i] === 4) {
array.splice(i, 1);
}
}
A. [1, 2, 3, 4, 5, 4, 4]
B. [1, 2, 3, 4, 4, 5, 4]
C. [1, 2, 3, 4, 5, 4]
D. [1, 2, 3, 5]
Answer: C
NEW QUESTION 74
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
Answer: C
NEW QUESTION 77
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.
Answer: C
NEW QUESTION 82
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:
Answer: AB
NEW QUESTION 84
Refer to code below:
What are the values for first and second once the code executes ?
Answer: D
NEW QUESTION 86
developer uses the code below to format a date.
Answer: A
NEW QUESTION 90
A developer wants to setup a secure web server with Node.js. The developer creates a directory locally called app-server, and the first file is app-server/index.js
Without using any third-party libraries, what should the developer add to index.js to create the secure web server?
Answer: A
NEW QUESTION 91
Which codestatement below correctly persists an objects in local Storage ?
Answer: A
NEW QUESTION 92
Refer to the code below:
Answer: C
NEW QUESTION 96
is below:
<input type=”file” onchange=”previewFile()”>
<img src=”” height=”200” alt=”Image Preview…”/> The JavaScript portion is:
1 function previewFile(){
2 const preview = document.querySelector(‘img’);
3 const file = document.querySelector(‘input[type=file]’).files[0]; 04 //line 4 code
05 reader.addEventListener(“load”, () =>{ 06 preview.src = reader.result;
7 },false);
8 //line 8 code
9}
In lines 04 and 08, which code allows the user to select an image from their local computer , and to display the image in the browser?
Answer: D
A. Integration
B. Black box
C. White box
D. Mocking
Answer: CD
A. [ ]. Concat.apply ([ ], inArray);
B. [ ]. Concat (... inArray);
C. [ ]. concat.apply(inArray, [ ]);
D. [ ]. concat ( [ ….inArray ] );
Answer: AB
Answer: BCD
Answer: C
Answer: B
Answer: A
Answer: A
A. console.log(10 / Number('5) ) ;
B. console.log(parseInt ' ("two')) ;
C. console.log(10 / 0);
D. console.loeg(10 / 'five');
Answer: BD
Answer: B
A. JSO
B. parse (""foo"');
C. JSON.parse (""foo'");
D. JSON.parse ("foo");
E. JSON.parse ("foo");
Answer: A
Answer: B
Where can the developer see the log statement after loading the page in the browser?
Answer: C
A. The function generated its own this making ituseful for separating the function’s scope from its enclosing scope.
B. The function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scop
C. If the function has a single expression in the function body, the expression will be evaluated and implicit returned.
D. The function uses the this from the enclosing scope.
Answer: AC
A. 104
B. 4100
C. ‘3100null’
D. ‘4100null’
Answer: D
Answer: A
Answer: A
A. node -i index.js
B. Node --inspect-brk index.js
C. Node inspect index.js
D. Node --inspect index.js
Answer: D
A. JSON.parse ( ‘ foo ’ );
B. JSON.parse ( “ foo ” );
C. JSON.parse( “ ‘ foo ’ ” );
D. JSON.parse(‘ “ foo ” ’);
Answer: D
Answer: C
Answer: AD
A. 0 0 1 2
B. 0 1 2 3
C. 0 1 1 2
D. 0 1 2 2
Answer: C
Which two implementations of Utils.js export foo and bar such that the code above runs without error?
Choose 2 answers
A.
B.
C.
D.
Answer: BC
Answer: D
Answer: B
Which two lines of code result in a second array, arr2 being created such that arr2 is not a reference to arr1?
Answer: AB
* JavaScript-Developer-I Most Realistic Questions that Guarantee you a Pass on Your FirstTry
* JavaScript-Developer-I Practice Test Questions in Multiple Choice Formats and Updatesfor 1 Year