Labour Day - Special 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70dumps

JavaScript-Developer-I Questions and Answers

Question # 6

Refer to the code below:

What is the value of result when the code executes?

A.

10-10

B.

5-5

C.

10-5

D.

5-10

Full Access
Question # 7

Which statement can a developer apply to increment the browser's navigation history without a page refresh?

Which statement can a developer apply to increment the browser's navigation history without a page refresh?

A.

window.history.pushState(newStateObject);

B.

window.history.pushStare(newStateObject, ' ', null);

C.

window.history.replaceState(newStateObject,'', null);

D.

window.history.state.push(newStateObject);

Full Access
Question # 8

At Universal Containers, every team has its own way of copyingJavaScript objects. The code snippet shows an Implementation from one team:

What is the output of the code execution?

A.

Hello John Doe

B.

Hello Dan

C.

Hello Dan Doe

D.

SyntaxError: Unexpected token in JSON

Full Access
Question # 9

Refer to the code:

Given the code above, which three properties are set pet1?

Choose 3 answers:

A.

Name

B.

canTalk

C.

Type

D.

Owner

E.

Size

Full Access
Question # 10

Refer to the following code:

What is the value of output on line 11?

A.

[1, 2]

B.

[‘’foo’’, ‘’bar’’]

C.

[‘’foo’’:1, ‘’bar’’:2’’]

D.

An error will occur due to the incorrect usage of the for…of statement on line 07.

Full Access
Question # 11

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

Full Access
Question # 12

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 areused to address this ?

Choose 2 answers

A.

Use the document object instead of the window object.

B.

Assign variables to the global object.

C.

Create a new window object in the root file.

D.

Assign variables to module.exports and require them as needed.

Full Access
Question # 13

Refer to the followingcode:

Full Access
Question # 14

After user acceptance testing, the developer is asked to change the webpage background based on user's location. This change was implemented and deployed for testing.

The tester reports that the background is not changing, however it works as required when viewing on the developer's computer.

Which two actions will help determine accurate results?

Choose 2 answers

A.

The developer should inspect their browser refresh settings.

B.

The tester should disable their browser cache.

C.

The developer should rework the code.

D.

The tester should dear their browser cache.

Full Access
Question # 15

A developer has a formatName function that takes two arguments, firstName and lastName and returns a string. They want to schedule the

function to run once after five seconds.

What is the correct syntax toschedule this function?

A.

setTimeout (formatName(), 5000, "John", "BDoe");

B.

setTimeout (formatName('John', ‘'Doe'), 5000);

C.

setTimout(() => { formatName("John', 'Doe') }, 5000);

D.

setTimeout ('formatName', 5000, 'John", "Doe');

Full Access
Question # 16

Refer to the HTML below:

Which JavaScript statement results in changing “ The Lion.”?

A.

document.querySelectorAll(‘$main $TONY’).innerHTML = ’“ The Lion

B.

document.querySelector(‘$main li:second-child’).innerHTML = “The Lion ’;

C.

document.querySelector(‘$main li.Tony’).innerHTML = ’“ The Lion ’;

D.

document.querySelector(‘$main li:nth-child(2)’),innerHTML = “ The Lion. ’;

Full Access
Question # 17

Given the following code:

document.body.addEventListener(‘ click ’, (event) => {

if (/* CODE REPLACEMENT HERE */) {

console.log(‘button clicked!’);

)

});

Which replacement for the conditional statement on line 02 allows a developer to

correctly determine that a button on page is clicked?

A.

Event.clicked

B.

e.nodeTarget ==this

C.

event.target.nodeName == ‘BUTTON’

D.

button.addEventListener(‘click’)

Full Access
Question # 18

Refer to the following code block:

class Animal{

constructor(name){

this.name = name;

}

makeSound(){

console.log(`${this.name} ismaking a sound.`)

}

}

class Dog extends Animal{

constructor(name){

super(name)

this.name = name;

}

makeSound(){

console.log(`${this.name} is barking.`)

}

}

let myDog = new Dog('Puppy');

myDog.makeSound();

What is the console output?

A.

Puppy is barking

Full Access
Question # 19

Given the code below:

Which three code segments result in a correct conversion from number to string? Choose 3 answers

A.

let strValue = numValue. toString();

B.

let strValue = * * 4 numValue;

C.

let strValue = numValue.toText ();

D.

let scrValue = String(numValue);

E.

let strValue = (String)numValue;

Full Access
Question # 20

Refer to code below:

Const objBook = {

Title: ‘Javascript’,

};

Object.preventExtensions(objBook);

Const newObjBook = objBook;

newObjectBook.author =‘Robert’;

What are the values of objBook and newObjBook respectively ?

A.

[title: “javaScript”] [title: “javaScript”]

B.

{author: “Robert”, title: “javaScript}

Undefined

C.

{author: “Robert”, title: “javaScript}

{author: “Robert”, title: “javaScript}

D.

{author: “Robert”}

{author: “Robert”, title: “javaScript}

Full Access
Question # 21

Refer to the code below:

Line 05 causes an error.

What are the values of greeting and salutation once code completes?

A.

Greeting is Hello and salutation is Hello, Hello.

B.

Greeting is Goodbye and salutation is Hello, Hello.

C.

Greeting is Goodbye and salutation is I say Hello.

D.

Greeting is Hello and salutation is I say hello.

Full Access
Question # 22

A class was written to represent items for purchase in an online store, and a secondclass

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

Full Access
Question # 23

A developer creates a class that represents a blog post based on the requirement that a

Post should have a body author and view count.

The Code shown Below:

Class Post{

// Insert code here

This.body =body

This.author = author;

this.viewCount = viewCount;

}

}

Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set

to a new instanceof a Post with the three attributes correctly populated?

A.

super (body, author, viewCount) {

B.

Function Post (body, author, viewCount) {

C.

constructor (body, author, viewCount) {

D.

constructor() {

Full Access
Question # 24

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

Full Access
Question # 25

Refer tofollowing code:

class Vehicle {

constructor(plate) {

This.plate =plate;

}

}

Class Truck extends Vehicle {

constructor(plate, weight) {

//Missing code

This.weight = weight;

}

displayWeight() {

console.log(‘The truck ${this.plate} has a weight of${this.weight} lb.’);}}

Let myTruck = new Truck(‘123AB’, 5000);

myTruck.displayWeight();

Which statement should be added to line 09 for the code to display ‘The truck 123AB has a

weight of 5000lb.’?

A.

Super.plate =plate;

B.

super(plate);

C.

This.plate =plate;

D.

Vehicle.plate = plate;

Full Access
Question # 26

Refer to the code below:

Let textValue = ’1984’;

Which code assignment shows a correct way to convert this string to an integer?

A.

let numberValue = Number(textValue);

B.

Let numberValue = (Number)textValue;

C.

Let numberValue = textValue.toInteger();

D.

Let numberValue = Integer(textValue);

Full Access
Question # 27

Refer the code below.

x=3.14;

function myfunction() {

"use strict";

y=x;

}

z=x;

myFunction();

Full Access
Question # 28

A developer at Universal Containers creates a new landing page based on HTML, CSS, and

JavaScript TO ensure that visitors have a goodexperience, a script named personaliseContext

needs to be executed when the webpage is fully loaded (HTML content and all related files ), in

order to do some custom initialization.

Which statement should be used to call personalizeWebsiteContent based onthe above

business requirement?

A.

document.addEventListener(‘’onDOMContextLoaded’, personalizeWebsiteContext);

B.

window.addEventListener(‘load’,personalizeWebsiteContext);

C.

window.addEventListener(‘onload’, personalizeWebsiteContext);

D.

Document.addEventListener(‘‘’DOMContextLoaded’ , personalizeWebsiteContext);

Full Access
Question # 29

A developer wants to iterate through an array of objects and count the objects and count

the objects whose property value, name, starts with the letterN.

Const arrObj = [{“name” : “Zach”} , {“name” : “Kate”},{“name” : “Alise”},{“name” : “Bob”},{“name” :

“Natham”},{“name” : “nathaniel”}

Refer to the code snippet below:

01 arrObj.reduce(( acc, curr) => {

02 //missing line 02

02 //missing line 03

04 ). 0);

Which missing lines 02 and 03 return the correct count?

A.

Const sum = curr.startsWith(‘N’) ? 1: 0;

Return acc +sum

B.

Const sum = curr.name.startsWith(‘N’) ? 1: 0;

Return acc +sum

C.

Const sum = curr.startsWIth(‘N’) ? 1: 0;

Return curr+ sum

D.

Const sum =curr.name.startsWIth(‘N’) ? 1: 0;

Return curr+ sum

Full Access
Question # 30

At Universal Containers, every team has its own way of copying JavaScript objects. The

code

Snippet shows an implementation from one team:

Function Person() {

this.firstName = “John”;

this.lastName = ‘Doe’;

This.name =() => (

console.log(‘Hello $(this.firstName) $(this.firstName)’);

)}

Const john = new Person ();

Const dan =JSON.parse(JSON.stringify(john));

dan.firstName =’Dan’;

dan.name();

What is the Output of the code execution?

A.

Hello Dan Doe

B.

Hello John DOe

C.

TypeError: dan.name is not a function

D.

TypeError: Assignment to constant variable.

Full Access
Question # 31

What is the result of the code block?

A.

The console logs only ‘flag’.

B.

The console logs ‘flag’ and another flag.

C.

An error is thrown.

D.

The console logs ‘flag’ and then an error is thrown.

Full Access
Question # 32

Refer to the following array:

Let arr = [1, 2, 3, 4, 5];

Which three options result in x evaluating as [1,2]?

Choose 3 answer

A.

let x = arr. slice (2);

B.

let x = arr. slice (0, 2);

C.

let x arr.filter((a) => (return a <= 2 });

D.

let x = arr.filter ((a) => 2 }) ;

E.

let x =arr.splice(0, 2);

Full Access