JavaScript-Developer-I Exam Questions

Total 221 Questions

Last Updated Exam : 22-Nov-2024

A developer creates a generic function to log custom messages in the console. To do this,
the function below is implemented.
01 function logStatus(status){
02 console./*Answer goes here*/{‘Item status is: %s’, status};
03 } Which three console logging methods allow the use of string substitution in line 02?


A.

Assert


B.

Log


C.

Message


D.

Info


E.

ErrorA





A.
  

Assert



D.
  

Info



Which code statement below correctly persists an objects in local Storage ?


A.

const setLocalStorage = (storageKey, jsObject) => {
window.localStorage.setItem(storageKey, JSON.stringify(jsObject));
}


B.

const setLocalStorage = ( jsObject) => {
window.localStorage.connectObject(jsObject));
}


C.

const setLocalStorage = ( jsObject) => {
window.localStorage.setItem(jsObject);
}


D.

const setLocalStorage = (storageKey, jsObject) => {
window.localStorage.persist(storageKey, jsObject);
}





A.
  

const setLocalStorage = (storageKey, jsObject) => {
window.localStorage.setItem(storageKey, JSON.stringify(jsObject));
}



Which statement phrases successfully?


A.

JSON.parse ( ‘ foo ’ );


B.

JSON.parse ( “ foo ” );


C.

JSON.parse( “ ‘ foo ’ ” );


D.

JSON.parse(‘ “ foo ” ’);





D.
  

JSON.parse(‘ “ foo ” ’);



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





C.
  

02413



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:
Class Item {
constructor(name, price) {
… // Constructor Implementation
}
}
Class SaleItem extends Item {
constructor (name, price, discount) {
...//Constructor Implementation
}
}
There is a new requirement for a developer to implement a description method that will
return a
brief description for Item and SaleItem.
Let regItem =new Item(‘Scarf’, 55);
Let saleItem = new SaleItem(‘Shirt’ 80, -1);
Item.prototype.description = function () { return ‘This is a ’ + this.name;
console.log(regItem.description());
console.log(saleItem.description());
SaleItem.prototype.description = function () { return ‘This is a discounted ’ +
this.name; }
console.log(regItem.description());
console.log(saleItem.description());
What is the output when executing the code above ?


A.

This is a Scarf
Uncaught TypeError: saleItem.description is not a function
This is aScarf
This is a discounted Shirt


B.

This is a Scarf
This is a Shirt
This is a Scarf
This is a discounted Shirt


C.

This is a Scarf
This is a Shirt
This is a discounted Scarf
This is a discounted Shirt


D.

This is aScarf
Uncaught TypeError: saleItem.description is not a function
This is a Shirt
This is a did counted Shirt





B.
  

This is a Scarf
This is a Shirt
This is a Scarf
This is a discounted Shirt



Refer to code below:
Let first = ‘who’;
Let second = ‘what’;
Try{
Try{
Throw new error(‘Sad trombone’);
}catch (err){
First =’Why’;
}finally {
Second =’when’;
} catch (err) {
Second =’Where’;
}
What are the values for first and second once the code executes ?


A.

First is Who and second is When


B.

First is why and second is where


C.

First is who and second is where


D.

First is why and second is when





D.
  

First is why and second is when



Given the following code

is the output of line 02?


A.

''x''


B.

''null'''


C.

''object''


D.

''undefined''





C.
  

''object''



Refer to the following code that performs a basic mathematical operation on a provided
input:
function calculate(num) {
Return (num +10) / 3;
}
How should line 02 be written to ensure that x evaluates to 6 in the line below?
Let x = calculate (8);


A.

Return Number((num +10) /3 );

 


B.

Return (Number (num +10 ) / 3;


C.

Return Integer(num +10) /3;


D.

Return Number(num + 10) / 3;





B.
  

Return (Number (num +10 ) / 3;



Refer to the code below:
Let foodMenu1 = [‘pizza’, ‘burger’, ‘French fries’];
Let finalMenu = foodMenu1;
finalMenu.push(‘Garlic bread’);
What is the value of foodMenu1 after the code executes?


A.

[ ‘pizza’,’Burger’, ‘French fires’, ‘Garlic bread’]


B.

[ ‘pizza’,’Burger’, ‘French fires’]


C.

[ ‘Garlic bread’ , ‘pizza’,’Burger’, ‘French fires’ ]


D.

[ ‘Garlic bread’]





B.
  

[ ‘pizza’,’Burger’, ‘French fires’]



Which statement parses successfully?


A.

JSON. parse (""foo"');


B.

JSON.parse (""foo'");


C.

JSON.parse ("foo");


D.

JSON.parse ("foo");





A.
  

JSON. parse (""foo"');




Page 10 out of 23 Pages
Previous