Set 1-2

A vibrant image depicting JavaScript code snippets, a laptop, and coffee, symbolizing programming and coding knowledge.

JavaScript Mastery Quiz

Test your knowledge of JavaScript concepts and coding practices with this engaging quiz! Whether you're a novice or an experienced developer, this quiz challenges you to think critically about JavaScript behavior, functions, and syntax.

Join now and explore:

  • 10 carefully crafted questions
  • Multiple choice and checkbox formats
  • Immediate feedback on your performance
10 Questions2 MinutesCreated by CodingNinja42
Refer to the code below:
 
01 const objBook - {
02     title: 'JavaScript',
03 };
04 Object.preventExtensions(objBook);
05 const newObjBook = objBook;
06 newObjBook.author = 'Robert';
 
What are the values of objBook and newObjBook respectively?
 
{ author: "Robert", title: "JavaScript" }
undefined
{ author: "Robert" }
{ author: "Robert", title: "JavaScript" }
{ author: "JavaScript" }
{ author: "JavaScript" }
{ author: "Robert", title: "JavaScript" }
{ author: "Robert", title: "JavaScript" }
Refer to the code below:
 
01 let foodMenu1 = {'Pizza', 'Burger', 'French fries'};
02 let finalMenu = foodMenu1;
03 let finalMenu.push('Garlic bread');
 
What is the value of foodMenu1 after the code executes?
{'Garlic bread', 'Pizza', 'Burger', 'French fries'}
{'Garlic bread'}
{'Pizza', 'Burger', 'French fries', 'Garlic bread'}
{'Pizza', 'Burger', 'French fries'}
A developer tries to retrieve all cookies, then sets a certain key value pair in the cookie. These statements are used:
 
01 document.cookie;
02 document.cookie = 'key=John Smith';
 
What is the behavior?
Cookies are read and the key value is set, and all cookies are wiped.
Cookies are read and the key value is set, the remaining cookies are unaffected.
Cookies are not read because line 01 should be document.cookies, but the key value is set and all cookies are wiped.
Cookies are read, but the key value is not set because the value is not URL encoded.
A developer uses the code below to format a date.
 
const date = new Date(2020, 11, 10);
cost dateDisplayOptions = {
year: 'numeric',
month: 'long',
day: 'numeric'
};
 
const formattedDate = date.toLocaleDateString('en', dateDisplayOptions);
 
After executing, what is the value of formattedDate?
December 10, 2020
November 11, 2020
October 11, 2020
November 10, 2020
A team that works on a big project uses npm to deal with the project's dependencies.
 
A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complains that the dependency does not get downloaded when they execute npm install.
 
Which two reasons could be possible explanations for this?
The developer missed the option --add when adding the dependency.
The developer missed the option --save when adding the dependency.
The developer added the dependency as a dev dependency, and NPM_ENV is set to production.
The developer added the dependency as a dev dependency, and NODE_ENV is set to production.
A developer creates a class that represents a news story based on the requirements that a Story should have a body, author, and view count. The code is shown below:
 
01 class Story {
02    // Insert code here
03         this.body = body;
04         this.author = author;
05         this.viewCount = viewCount;
06    }
07 }
 
Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instance of a Story with the three attributes correctly populated?
Function Story(body, author, viewCount) {)
Super (body, author, viewCount) {)
Constructor(body, author, viewCount) {)
Constructor() {
Given the code below: 
 
01 function Person() {
02    this.firstName = 'John';
03 }
04
05 Person.proto = {
06    job: x => 'Developer'
07 };
08
09 const myFather = new Person();
10 const result = myFather.firstName + ' ' + myFather.job();
 
What is the value of result when line 10 executes?
John Developer
Error: myFather.job is not a function
Undefined Developer
John undefined
Which statement accurately describes an aspect of promises?
.then() manipulates and returns the original promise.
.then() cannot be added after a catch.
In a .then() function, returning results is not necessary since callbacks will catch the result of a previous promise.
Arguments for the callback function passed to .then() are optional.
Refer to the 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 > 10){
break;
}
if(num % 2 == 0){
continue;
}
output += num;
}
 
What is the value of output after the code executes?
16
25
11
36
Refer to the code below:
 
let sayHello = () => {
console.log('Hello, World!');
};
 
Which options executes sayHello once every two minutes?
Delay(sayHello, 120000);
SetInterval(sayHello, 120000);
SetTimeout(sayHello, 120000);
SetTimeout(sayHello(), 120000);
{"name":"Set 1-2", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge of JavaScript concepts and coding practices with this engaging quiz! Whether you're a novice or an experienced developer, this quiz challenges you to think critically about JavaScript behavior, functions, and syntax.Join now and explore:10 carefully crafted questionsMultiple choice and checkbox formatsImmediate feedback on your performance","img":"https:/images/course4.png"}
Powered by: Quiz Maker