JavaScript-Developer-I Exam Questions

Total 221 Questions

Last Updated Exam : 22-Oct-2024

Refer to the following array

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


A.

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


B.

Let arr2 = Array.from(arr1);


C.

Let arr2 = arr1;


D.

Let arr2 = arr1.sort();





A.
  

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



B.
  

Let arr2 = Array.from(arr1);



Refer to the code snippet:
Function getAvailabilityMessage(item) {
If (getAvailability(item)){
Var msg =”Username available”;
}
Return msg;
}
A developer writes this code to return a message to user attempting 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





D.
  

undefined



Refer to the code below:
Async funct on functionUnderTest(isOK) {
If (isOK) return ‘OK’ ;
Throw new Error(‘not OK’);
)
Which assertion accuretely tests the above code?


A.

Console.assert (await functionUnderTest(true), ‘ OK ’)


B.

Console.assert (await functionUnderTest(true), ‘ not OK ’)


C.

Console.assert (await functionUnderTest(true), ‘ not OK ’)


D.

Console.assert (await functionUnderTest(true), ‘OK’)





D.
  

Console.assert (await functionUnderTest(true), ‘OK’)



Considering type coercion, what does the following expression evaluate to?
True + ‘13’ + NaN


A.

‘ 113Nan ’


B.

14


C.

‘ true13 ’


D.

‘ true13NaN ’





D.
  

‘ true13NaN ’



Which two console logs output NaN?
Choose 2 answers | |


A.

console.log(10 / Number('5) ) ;


B.

console.log(parseInt ' ("two')) ;


C.

console.log(10 / 0);


D.

console.loeg(10 / 'five');





B.
  

console.log(parseInt ' ("two')) ;



D.
  

console.loeg(10 / 'five');



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:


A.

console.assert( arr.length === 5 );


B.

arr.forEach(elem => console.assert(elem === 0)) ;


C.

console.assert(arr[0] === 0 && arr[ arr.length] === 0);


D.

console.assert (arr.length >0);





A.
  

console.assert( arr.length === 5 );



B.
  

arr.forEach(elem => console.assert(elem === 0)) ;



Consider type coercion, what does the following expression evaluate to?
True + 3 + ‘100’ + null


A.

104


B.

4100


C.

‘3100null’


D.

‘4100null’





D.
  

‘4100null’



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





B.
  

2 5 1 3 4



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


A.

document.getElementById(“status”).Value = ’Completed’ ;


B.

document.getElementById(“#status”).innerHTML = ’Completed’ ;


C.

document.getElementById(“status”).innerHTML = ’Completed’ ;


D.

document.getElementById(“.status”).innerHTML = ’Completed’ ;





C.
  

document.getElementById(“status”).innerHTML = ’Completed’ ;



Which two console logs outputs NaN ?
Choose 2 answers


A.

console.log(10/ Number(‘5’));


B.

console.log(parseInt(‘two’));


C.

console.log(10/ ‘’five);


D.

console.log(10/0);





B.
  

console.log(parseInt(‘two’));



C.
  

console.log(10/ ‘’five);




Page 11 out of 23 Pages
Previous