Exam Code : Javascript-Developer-I
Exam Name : Salesforce Certified JavaScript Developer I
Vendor Name :
"SalesForce"
Javascript-Developer-I Dumps Javascript-Developer-I Braindumps Javascript-Developer-I Real Questions Javascript-Developer-I Practice Test Javascript-Developer-I Actual Questions
Salesforce Certified JavaScript Developer I
https://killexams.com/pass4sure/exam-detail/Javascript-Developer-I
Question: 1
Which three statements are true about promises? Choose 3 answers
The executor of a new Promise runs automatically.
A Promise has a .then() method.
A fulfilled or rejected promise will not change states .
A settled promise can become resolved.
A pending promise can become fulfilled, settled, or rejected.
Question: 2
bar, awesome is a popular JavaScript module. the versions publish to npm are:
Teams at Universal Containers use this module in a number of projects. A particular project has the package, json definition below.
A developer runs this command: npm install. Which version of bar .awesome is installed?
A. 1.3.1
B. 1.3.5
C. The command fails, because version 130 is not found D. 1.4.0
Question: 3
A test has a dependency on database.query. During the test the dependency is replaced with an object called database with the method, query, that returns an array. The developer needs to verify how many times the method was called
and the arguments used each time.
Which two test approaches describe the requirement? Choose 2 answers
Integration
Black box
White box
Mocking
Question: 4
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:
Non-primitive values are mutable.
Non-primitive values are immutable.
Primitive values are mutable.
Primitive values are immutable.
Question: 5
Refer to the code below: Const pi = 3.1415326, What is the data type of pi?
Double
Number
Decimal
Float
Question: 6
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 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 the array.
Which two results occur when running this test on the updated sum3 function? Choose 2 answers
The line 05 assertion passes.
The line 02 assertion passes.
The line 02 assertion fails.
The line 05 assertion fails.
Question: 7
Question: 8
developer has a web server running with Node.js. The command to start the web server is node server,js. The web server started having latency issues. Instead of a one second turn around for web requests, the developer now sees a five second turnaround,
Which command can the web developer run to see what the module is doing during the latency period?
DEBUG = http, https node server.js
NODE_DEBUG =http, https node server.js
DEBUG =true node server.js
NODE_DEBUG =true node server.js
Question: 9
Question: 10
Question: 11
A developer has an ErrorHandler module that contains multiple functions. What kind of export be leverages so that multiple functions can be used?
Named
All
Multi
Default
Question: 12
Question: 13
Refer to HTML below:
<p> The current status of an Order: <span id =”status”> In Progress </span> </p>. Which JavaScript statement changes the text ‘In Progress’ to ‘Completed’?
document.getElementById(“status”).Value = ’Completed’ ;
document.getElementById(“#status”).innerHTML = ’Completed’ ;
document.getElementById(“status”).innerHTML = ’Completed’ ;
document.getElementById(“.status”).innerHTML = ’Completed’ ;
Question: 14
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:
console.assert( arr.length === 5 );
arr.forEach(elem => console.assert(elem === 0)) ;
console.assert(arr[0] === 0 && arr[ arr.length] === 0);
console.assert (arr.length >0);
Question: 15
Refer to the code below:
Line 05 causes an error.
What are the values of greeting and salutation once code completes?
Greeting is Hello and salutation is Hello, Hello.
Greeting is Goodbye and salutation is Hello, Hello.
Greeting is Goodbye and salutation is I say Hello.
Greeting is Hello and salutation is I say hello.
Question: 16
Which two console logs outputs NaN? Choose 2 answers
console.log(10/ Number(‘5’));
console.log(parseInt(‘two’));
console.log(10/ ‘’five);
console.log(10/0);
Question: 17
A developer wants to leverage a module to print a price in pretty format, and has imported a method as shown below: Import printPrice from ‘/path/PricePrettyPrint.js’;
Based on the code, what must be true about the printPrice function of the PricePrettyPrint module for this import to work?
printPrice must be be a named export
printPrice must be an all export
printPrice must be the default export
printPrice must be a multi exportc
Question: 18
The developer wants to test this code:
Const toNumber =(strOrNum) => strOrNum;
Which two tests are most accurate for this code? Choose 2 answers
console.assert(toNumber(‘2’) === 2);
console.assert(Number.isNaN(toNumber()));
console.assert(toNumber(‘-3’) < 0);
console.assert(toNumber () === NaN);
Question: 19
A developer creates an object where its properties should be immutable and prevent properties from being added or modified.
Which method should be used to execute this business requirement?
Object.const()
Object.eval()
Object.lock()
Object.freeze()
Question: 20
Refer to HTML below:
<div id =”main”>
<div id = “ card-00”>This card is smaller.</div>
<div id = “card-01”>The width and height of this card is determined by its contents.</div>
</div>
Which expression outputs the screen width of the element with the ID card-01?
document.getElementById(‘ card-01 ’).getBoundingClientRest().width
document.getElementById(‘ card-01 ’).style.width
document.getElementById(‘ card-01 ’).width
document.getElementById(‘ card-01 ’).innerHTM
lenght*e
Question: 21
A developer wrote a fizzbuzz function that when passed in a number, returns the following: ‘Fizz’ if the number is divisible by 3.
‘Buzz’ if the number is divisible by 5.
‘Fizzbuzz’ if the number is divisible by both 3 and 5. Empty string if the number is divisible by neither 3 or 5.
Which two test cases will properly test scenarios for the fizzbuzz function? Choose 2 answers
let res = fizzbuzz(5); console.assert ( res === ‘ ’ );
let res = fizzbuzz(15); console.assert ( res === ‘ fizzbuzz ’ )
let res = fizzbuzz(Infinity); console.assert ( res === ‘ ’ )
let res = fizzbuzz(3); console.assert ( res === ‘ buzz ’ )
Question: 22
Question: 23
Question: 24
Why would a developer specify a package.jason as a developed forge instead of a dependency?
It is required by the application in production.
It is only needed for local development and testing.
Other required packages depend on it for development.
It should be bundled when the package is published.
Question: 25
Which three options show valid methods for creating a fat arrow function? Choose 3 answers
x => ( console.log(‘ executed ’) ; )
[ ] => ( console.log(‘ executed ’)
( ) => ( console.log(‘ executed ’)
X,y,z => ( console.log(‘ executed ’)
(x,y,z) => ( console.log(‘ executed ’)
Question: 26
Refer to the code below:
Let inArray =[ [ 1, 2 ] , [ 3, 4, 5 ] ];
Which two statements result in the array [1, 2, 3, 4, 5]? Choose 2 answers
[ ]. Concat.apply ([ ], inArray);
[ ]. Concat (… inArray);
[ ]. concat.apply(inArray, [ ]);
[ ]. concat ( [ ….inArray ] );
Answer: A,B
Question: 27 Given code below:
setTimeout (() => ( console.log(1);
). 0);
console.log(2);
New Promise ((resolve, reject )) = > ( setTimeout(() => ( reject(console.log(3));
). 1000);
)).catch(() => ( console.log(4);
));
console.log(5);
What is logged to the console? A. 2 1 4 3 5
B. 2 5 1 3 4
C. 1 2 4 3 5
D. 1 2 5 3 4
Question: 28
Refer to code below: Let a =’a’;
Let b;
// b = a; console.log(b);
What is displayed when the code executes?
Reference Error: b is not defined
A
Undefined
Null
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 are used to address this? Choose 2 answers
Use the document object instead of the window object.
Assign variables to the global object.
Create a new window object in the root file.
Assign variables to module.exports and require them as needed.
Question: 31
A developer has a web server running with Node.js. The command to start the web server is node server.js. The web server started having latency issues. Instead of a one second turnaround for web requests, the developer now sees a five second turnaround.
Which command can the web developer run to see what the module is doing during the latency period?
NODE_DEBUG=true node server.js
DEBUG=http, https node server.js
NODE_DEBUG=http,https node server.js
DEBUG=true node server.js
Question: 32
Question: 33
A developer needs to test this function: 01 const sum3 = (arr) => (
if (!arr.length) return 0,
if (arr.length === 1) return arr[0],
if (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
console.assert(sum3(1, ‘2’)) == 12);
console.assert(sum3(0)) == 0);
console.assert(sum3(-3, 2 )) == -1);
console.assert(sum3(‘hello’, 2, 3, 4)) === NaN);
Question: 34
Question: 35
Refer to the code below: Let textValue = ’1984’;
Which code assignment shows a correct way to convert this string to an integer?
let numberValue = Number(textValue);
Let numberValue = (Number)textValue;
Let numberValue = textValue.toInteger();
Let numberValue = Integer(textValue);
Question: 36
Given two expressions var1 and var2 .
What are two valid ways to return the logical AND of the two expressions and ensure it is data type Boolean? Choose 2 answers:
Boolean(var1 && var2)
var1 && var2
var1.toBoolean() && var2toBoolean()
Boolean(var1) && Boolean(var2)
Question: 37
Question: 38
Question: 39
Refer to the code below?
Let searchString = ‘ look for this ’;
Which two options remove the whitespace from the beginning of searchString? Choose 2 answers
searchString.trimEnd();
searchString.trimStart();
trimStart(searchString);
searchString.replace(/*ss*/, ‘’);
Refer to the code below:
Which value can a developer expect when referencing country,capital,city String?
‘London’
undefined
An error
‘NaN’
Question: 42
Question: 43
developer is trying to convince management that their team will benefit from using Node.js for a backend server that they are going to create. The server will be a web server that handles API requests from a website that the team has already built using HTML, CSS, and JavaScript.
Which three benefits of Node.js can the developer use to persuade their manager? Choose 3 answers:
Installs with its own package manager to install and manage third-party libraries.
Ensures stability with one major release every few years.
Performs a static analysis on code before execution to look for runtime errors.
Executes server-side JavaScript code to avoid learning a new language.
User non blocking functionality for performant request handling .
Question: 44
Question: 45
Question: 46
Question: 47
True + 3 + ‘100’ + null A. 104
4100
‘3100null’
‘4100null’
Question: 48
Refer to code below:
Let productSKU = ‘8675309’ ;
A developer has a requirement to generate SKU numbers that are always 19 characters lon, starting with ‘sku’, and padded with zeros.
Which statement assigns the values sku 0000000008675309?
productSKU = productSK
padStart (19. ‘0’).padstart(‘sku’);
productSKU = productSK
padEnd (16. ‘0’).padstart(‘sku’);
productSKU = productSK
padEnd (16. ‘0’).padstart(19, ‘sku’);
productSKU = productSK
padStart (16. ‘0’).padstart(19, ‘sku’);
Question: 49
Question: 50
Question: 51
Question: 52
Question: 53
Refer of the string below: Const str = ‘sa;esforce’=;
Which two statement result in the word ‘Sale’? Choose 2 answers
str, substring (0,5) ;
str, substr(0,5) ;
str, substring(1,5) ;
str, substr(1,5) ;
Question: 54
Question: 55
Universal Containers (UC) notices that its application that allows users to search for accounts makes a network request each time a key is pressed. This results in too many requests for the server to handle.
Address this problem, UC decides to implement a debounce function on string change handler. What are three key steps to implement this debounce function? Choose 3 answers:
If there is an existing setTimeout and the search string change, allow the existing setTimeout to finish, and do not
enqueue a new setTimeout.
When the search string changes, enqueue the request within a setTimeout.
Ensure that the network request has the property debounce set to true.
If there is an existing setTimeout and the search string changes, cancel the existing setTimeout using the persisted timerId and replace it with a new setTimeout.
Store the timeId of the setTimeout last enqueued by the search string change handle.
Question: 56
What are two unique features of functions defined with a fat arrow as compared to normal function definition? Choose 2 answers
The function generated its own this making it useful for separating the function’s scope from its enclosing scope.
The function receives an argument that is always in scope, called parent This, which is the enclosing lexical scope.
If the function has a single expression in the function body, the expression will be evaluated and implicit returned.
The function uses the this from the enclosing scope.
Question: 57
Refer to the code below:
After running this code, which result is displayed on the console?
> true > false
> 5 >undefined C. > 5 > -1
D. > 5 > 0
Question: 58
Which three browser specific APIs are available for developers to persist data between page loads? Choose 3 answers
IIFEs
indexedDB
Global variables
Cookies
localStorage.
Question: 59
Which statement phrases successfully?
JSO
parse ( ‘ foo ’ );
JSO
parse ( “ foo ” );
JSO
parse( “ ‘ foo ’ ” );
JSO
parse(‘ “ foo ” ’);
Question: 60
Which statement parses successfully?
JSO
parse (""foo"’);
JSO
parse (""foo’");
JSO
parse ("foo");
JSO
parse ("foo");
Question: 61
Given HTML below:
<div>
<div id =”row-uc”> Universal Container</div>
<div id =”row-aa”>Applied Shipping</div>
<div id =”row-bt”> Burlington Textiles </div>
</div>
Which statement adds the priority = account CSS class to the universal COntainers row?
Document .querySelector(‘#row-uc’).classes.push(‘priority-account’);
Document .queryElementById(‘row-uc’).addclass(‘priority-account’);
Document .querySelector(‘#row-uc’).classList.add(‘priority-account’);
Document .querySelectorALL(‘#row-uc’).classList.add(‘priority-account’);
Question: 62
Question: 63
Which option is a core Node,js module?
Path
Ios
Memory
locate
Question: 64
Which three actions can be using the JavaScript browser console? Choose 3 answers:
View and change DOM the page.
Display a report showing the performance of a page.
Run code that is not related to page.
view, change, and debug the JavaScript code of the page.
View and change security cookies.
Question: 65
Question: 66
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:
Let res = sum2([1, 2, 3 ]) ; console.assert(res === 6 ); Res = sum3([ 1, 2, 3, 4]);
console.assert(res=== 6);
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
The line 02 assertion passes.
The line 02 assertion fails
The line 05 assertion passes.
The line 05 assertion fails.
Question: 67
developer wants to use a module named universalContainersLib and them call functions from it.
How should a developer import every function from the module and then call the fuctions foo and bar?
import * ad lib from ‘/path/universalContainersLib.js’; lib.foo();
lib.bar();
import (foo, bar) from ‘/path/universalContainersLib.js’; foo();
bar();
import all from ‘/path/universalContaineraLib.js’; universalContainersLib.foo(); universalContainersLib.bar();
import * from ‘/path/universalContaineraLib.js’; universalContainersLib.foo(); universalContainersLib.bar();
Question: 68
Question: 69
Question: 70
Question: 71
Which javascript methods can be used to serialize an object into a string and deserialize a JSON string into an object, respectively?
JSO
stringify and JSO
parse
JSO
serialize and JSO
deserialize
JSO
encode and JSO
. decode
. JSO
. parse and JSO
. deserialize
Question: 72
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?
Promise.reject(‘cool error here’).then(error => console.error(error));
Promise.reject(‘cool error here’).catch(error => console.error(error));
New Promise((resolve, reject) => (throw ‘cool error here’}).catch(error => console.error(error)) ;
New Promise(() => (throw ‘cool error here’}).then(null, error => console.error(error)));
Question: 73
Refer to the code below:
Const searchTest = ‘Yay! Salesforce is amazing!” ; Let result1 = searchText.search(/sales/i);
Let result 21 = searchText.search(/sales/i); console.log(result1);
console.log(result2);
After running this code, which result is displayed on the console?
> true > false
> 5 >undefined C. > 5 > -1
D. > 5 > 0
Question: 74
Question: 75
Question: 76
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:
console.assert( arr.length === 5 );
arr.forEach(elem => console.assert(elem === 0)) ;
console.assert(arr[0] === 0 && arr[ arr.length] === 0);
console.assert (arr.length >0);
Question: 77
Why would a developer specify a package.jason as a developed forge instead of a dependency?
It is required by the application in production.
It is only needed for local development and testing.
Other required packages depend on it for development.
It should be bundled when the package is published.
Question: 78
Question: 79
developer is trying to convince management that their team will benefit from using Node.js for a backend server that they are going to create. The server will be a web server that handles API requests from a website that the team has already built using HTML, CSS, and JavaScript.
Which three benefits of Node.js can the developer use to persuade their manager? Choose 3 answers:
I nstalls with its own package manager to install and manage third-party libraries.
Ensures stability with one major release every few years.
Performs a static analysis on code before execution to look for runtime errors.
Executes server-side JavaScript code to avoid learning a new language.
User non blocking functionality for performant request handling.
Question: 80
Question: 81
Question: 82
Refer to the expression below: Let x = (‘1’ + 2) == (6 * 2);
How should this expression be modified to ensure that evaluates to false? A. Let x = (‘1’ + ‘ 2’) == ( 6 * 2);
B. Let x = (‘1’ + 2) == ( 6 * 2);
C. Let x = (1 + 2) == ( ‘6’ / 2);
D. Let x = (1 + 2 ) == ( 6 / 2);
Question: 83
Question: 84
A test has a dependency on database.query. During the test the dependency is replaced with an object called database with the method, query, that returns an array. The developer needs to verify how many times the method was called and the arguments used each time.
Which two test approaches describe the requirement? Choose 2 answers
Integration
Black box
White box
Mocking
Question: 85
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 are used to address this? Choose 2 answers
Use the document object instead of the window object.
Assign variables to the global object.
Create a new window object in the root file.
Assign variables to module.exports and require them as needed.
Question: 86
Question: 87
Question: 88
Question: 89
Given the following code:
Let x =(‘15’ + 10)*2;
What is the value of a? A. 3020
1520
50
35
Question: 90
Which option is a core Node,js module?
Path
Ios
Memory
locate
Question: 91
developer removes the HTML class attribute from the checkout button, so now it is simply:
<button>Checkout</button>.
There is a test to verify the existence of the checkout button, however it looks for a button with class= “blue”. The test fails because no such button is found.
Which type of test category describes this test?
True positive
True negative
False positive
False negative
Question: 92
Which option is a core Node,js module?
Path
Ios
Memory
locate
Question: 93
Question: 94
Question: 95
A developer needs to test this function: 01 const sum3 = (arr) => (
if (!arr.length) return 0,
if (arr.length === 1) return arr[0],
if (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
console.assert(sum3(1, ‘2’)) == 12);
console.assert(sum3(0)) == 0);
console.assert(sum3(-3, 2 )) == -1);
console.assert(sum3(‘hello’, 2, 3, 4)) === NaN);
Question: 96
Question: 97
A developer creates an object where its properties should be immutable and prevent properties from being added or modified.
Which method should be used to execute this business requirement?
Object.const()
Object.eval()
Object.lock()
Object.freeze()
Question: 98
Question: 99
Question: 100
Question: 101
Question: 102
Question: 103
Question: 104
Refer to the code:
Given the code above, which three properties are set pet1? Choose 3 answers:
Name
canTalk
Type
Owner
Size
Question: 105
Question: 106
Which option is a core Node,js module?
Path
Ios
Memory
locate
Question: 107
Question: 108
Which three statements are true about promises? Choose 3 answers
The executor of a new Promise runs automatically.
A Promise has a .then() method.
A fulfilled or rejected promise will not change states .
A settled promise can become resolved.
A pending promise can become fulfilled, settled, or rejected.
Question: 109
developer has a web server running with Node.js. The command to start the web server is node server,js. The web server started having latency issues. Instead of a one second turn around for web requests, the developer now sees a five second turnaround,
Which command can the web developer run to see what the module is doing during the latency period?
DEBUG = http, https node server.js
NODE_DEBUG =http, https node server.js
DEBUG =true node server.js
NODE_DEBUG =true node server.js
Question: 110
In which situation should a developer include a try .. catch block around their function call?
The function has an error that should not be silenced.
The function results in an out of memory issue.
The function might raise a runtime error that needs to be handled.
The function contains scheduled code.
Question: 111
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 the developer implement the request?
Let arr1 = arr.filter(( val) => ( return val > 15 )) .map (( num) => ( return num *2 ))
Let arr1 = arr.mapBy (( num) => ( return num *2 )) .filterBy (( val ) => return val > 15 )) ;
Let arr1 = arr.map((num) => num*2). Filter (( val) => val > 15);
Let arr1 = arr.map((num) => ( num *2)).filterBy((val) => ( val >15 ));
Question: 112
Which statement accurately describes the behaviour of the async/ await keyworks?
The associated class contains some asynchronous functions.
The associated function will always return a promise
The associated function can only be called via asynchronous methods
The associated sometimes returns a promise.
Question: 113
Works in both the browser and Node.js Which meet the requirements?
assert (number % 2 === 0);
console.error(number % 2 === 0);
console.debug(number % 2 === 0);
console.assert(number % 2 === 0);