JavaScript-Developer-I Exam Questions

Total 221 Questions

Last Updated Exam : 22-Nov-2024

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 is displayed 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





C.
  2 2 1 2

Universal Container(UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions that cause this problem. To verify this, the developer decides to do everything and log the time each of these three suspicious functions consumes.
console.time(‘Performance’);
maybeAHeavyFunction();
thisCouldTakeTooLong();
orMaybeThisOne();
console.endTime(‘Performance’);
Which function can the developer use to obtain the time spent by every one of the three functions?


A. console.timeLog()


B. console.getTime()


C. console.trace()


D. console.timeStamp()





A.
  console.timeLog()

Refer to the code below:
01 let car1 = new promise((_, reject) =>
02 setTimeout(reject, 2000, “Car 1 crashed in”));
03 let car2 = new Promise(resolve => setTimeout(resolve, 1500, “Car 2
completed”));
04 let car3 = new Promise(resolve => setTimeout (resolve, 3000, “Car 3
Completed”));
05 Promise.race([car1, car2, car3])
06 .then(value => (
07 let result = $(value) the race. `;
08 ))
09 .catch( arr => (
10 console.log(“Race is cancelled.”, err);
11 ));
What is the value of result when Promise.race executes?


A. Car 3 completed the race.


B. Car 1 crashed in the race.


C. Car 2 completed the race.


D. Race is cancelled.





C.
  Car 2 completed the race.

is below:

< img src=”” height=”200” alt=”Image Preview…”/>
The JavaScript portion is:

01 functionpreviewFile(){
02 const preview = document.querySelector(‘img’);
03 const file = document.querySelector(‘input[type=file]’).files[0];
04 //line 4 code
05 reader.addEventListener(“load”, () => {
06 preview.src = reader.result;
07 },false);
08 //line 8 code
09 }
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?


A. 04 const reader = new File(); 08 if (file) URL.createObjectURL(file);


B. 04 const reader = new FileReader(); 08 if (file) URL.createObjectURL(file);


C. 04 const reader = new File(); 08 if (file) reader.readAsDataURL(file);





D.
  

GIven a value, which three options can a developer use to detect if the value is NaN?
Choose 3 answers !


A. value == NaN


B. Object.is(value, NaN)


C. value === Number.NaN


D. value ! == value


E. Number.isNaN(value)





A.
  value == NaN

E.
  Number.isNaN(value)

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 ?


A. import * ad lib from ‘/path/universalContainersLib.js’;
lib.foo();
lib.bar();


B. import (foo, bar) from ‘/path/universalContainersLib.js’;
foo();
bar();


C. import all from ‘/path/universalContaineraLib.js’;
universalContainersLib.foo();
universalContainersLib.bar();


D. import * from ‘/path/universalContaineraLib.js’;
universalContainersLib.foo();
universalContainersLib.bar();





A.
  import * ad lib from ‘/path/universalContainersLib.js’;
lib.foo();
lib.bar();


A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint for debugging. Function Car (maxSpeed, color){
This.maxspeed =masSpeed;
This.color = color;
Let carSpeed = document.getElementById(‘ CarSpeed’);
Debugger;
Let fourWheels =new Car (carSpeed.value, ‘red’);
When the code execution stops at the breakpoint on line 06, which two types of information are available in the browser console ? Choose 2 answers:


A. The values of the carSpeed and fourWheels variables


B. A variable displaying the number of instances created for the Car Object.


C. The style, event listeners and other attributes applied to the carSpeed DOM element


D. The information stored in the window.localStorage property





C.
  The style, event listeners and other attributes applied to the carSpeed DOM element

D.
  The information stored in the window.localStorage property

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


A. Integration


B. Black box


C. White box


D. Mocking





C.
  White box

D.
  Mocking

Refer to the following code that imports a module named utils:
import (foo, bar) from ‘/path/Utils.js’;
foo() ;
bar() ;
Which two implementations of Utils.js export foo and bar such that the code above runs
without
error?
Choose 2 answers


A.

// FooUtils.js and BarUtils.js exist
Import (foo) from ‘/path/FooUtils.js’;
Import (boo) from ‘ /path/NarUtils.js’;


B.

const foo = () => { return ‘foo’ ; }
const bar = () => { return ‘bar’ ; }
export { bar, foo }


C.

Export default class {
foo() { return ‘foo’ ; }
bar() { return ‘bar’ ; }
}


D.

const foo = () => { return ‘foo’;}
const bar = () => {return ‘bar’; }
Export default foo, bar;





B.
  

const foo = () => { return ‘foo’ ; }
const bar = () => { return ‘bar’ ; }
export { bar, foo }



C.
  

Export default class {
foo() { return ‘foo’ ; }
bar() { return ‘bar’ ; }
}



Given the following code:
Counter = 0;
const logCounter = () => {
console.log(counter);
);
logCounter();
setTimeout(logCOunter, 1100);
setInterval(() => {
Counter++
logCounter();
}, 1000);
What is logged by the first four log statements?


A. A. 0 0 1 2


B. 0 1 2 3


C. 0 1 1 2


D. 0 1 2 2





C.
  0 1 1 2


Page 1 out of 23 Pages