New Year Sale Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmas50

Salesforce JavaScript-Developer-I - Salesforce Certified JavaScript Developer (JS-Dev-101)

Page: 2 / 7
Total 219 questions

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

Considering the implications of 'use strict' on line 04, which three statements describe the execution of the code?

Choose 3 answers

A.

z is equal to 3.14.

B.

'use strict' is hoisted, so it has an effect on all lines.

C.

'use strict' has an effect only on line 05.

D.

'use strict' has an effect between line 04 and the end of the file.

E.

Line 05 throws an error.

A developer has an is Dog function that takes one argument cat. They want to schedule the function to run every minute.

What is the correct syntax for scheduling this function?

A.

setInterval(isDog, 60000,'cat');

A developer is setting up a new Node.js server with a client library that is built using events and callbacks.

The library:

● Will establish a web socket connection and handle receipt of messages to theserver

● Will be imported with require, and made available with a variable called we.

The developer also wants to add error logging if a connection fails.

Given this info, which code segment shows the correct way to set up a client with two events that listen at execution time?

A.

ws.connect (( ) => {console.log(‘connected to client’); }).catch((error) => { console.log(‘ERROR’ , error); }};

B.

ws.on (‘connect’, ( ) => {console.log(‘connected to client’); ws.on(‘error’, (error) => { console.log(‘ERROR’ ,error); });}); C. ws.on (‘connect’, ( ) => { console.log(‘connected to client’); }}; ws.on(‘error’, (error) => { console.log(‘ERROR’ , error); }};

C.

try{ws.connect (( ) => {console.log(‘connected to client’); });} catch(error) { console.log(‘ERROR’ ,error); };}

Given the code below:

Setcurrent URL ();

console.log(‘The current URL is: ‘ +url );

functionsetCurrentUrl() {

Url = window.location.href:

What happens when the code executes?

A.

The url variable has local scope and line 02 throws an error.

B.

The url variable has global scope and line 02 executes correctly.

C.

The url variable has global scope and line 02 throws an error.

D.

The url variable has local scope and line 02 executes correctly.

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;

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);

Refer to the code below:

Which value can a developer expect when referencing country,capital,cityString?

A.

'London'

B.

undefined

C.

An error

D.

'NaN'

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

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.