Master JS-Dev-101: Salesforce Certified JavaScript Developer Exam Success
Refer to the code below:
01 funetion Person() (
02 thie. fixsttane = "Zoha'y
os}
05 Perscn.prototype = [
06 jek: x => 'Developer'
onde
09 const myFather = new Peracn():
10 const result = myFather.firstiame + ' * + myFather.jeb()
What is the value of result after line 10 executes?
Correct : A
Start a Discussions
01 class Student {
02 constructor(name) {
03 this._name = name;
04 }
05 displayGrade() {
06 console.log(`${this._name} got 70% on test.`);
07 }
08 }
09
10 class GraduateStudent extends Student {
11 constructor(name) {
12 super(name);
13 this._name = "Graduate Student " + name;
14 }
15 displayGrade() {
16 console.log(`${this._name} got 100% on test.`);
17 }
18 }
19 let student = new GraduateStudent("Jane");
20 student.displayGrade();
```
What is the console output?:
Correct : C
Start a Discussions
A developer wants to use a module named universalContainerslib and then call functions from it. How should a developer import every function from the module and then call the functions foo and bar?
Correct : A
import * as lib from '...' imports all named exports from the module into the namespace object lib.
You then call:
lib.foo();
lib.bar();
Option D correctly imports only foo and bar, not every function. The question explicitly says ''import every function... and then call foo and bar'', so A best matches.
Options B and C are invalid syntax or reference the wrong identifier.
________________________________________
Start a Discussions
01 function Monster() { this.name = 'hello'; };
02 const m = Monster();
What happens due to the missing new keyword?
Correct : B
________________________________________
Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge
In JavaScript, when calling a constructor function without new:
const m = Monster();
the following happens:
The function executes as a normal function, not as a constructor.
Inside a regular function (in non-strict mode), this refers to the global object:
In a browser: window
So the line:
this.name = 'hello';
becomes:
window.name = 'hello';
Since Monster() does not return anything, its return value is undefined:
const m = undefined;
Therefore:
m is undefined
window.name becomes 'hello'
This matches option B.
________________________________________
JavaScript Knowledge Reference (text-only)
Calling a function without new uses the global object as this in non-strict mode.
Constructor functions must use new to create a new object.
Functions without an explicit return return undefined.
Start a Discussions
Refer to the code below:
01 let timedFunction = () => {
02 console.log('Timer called.');
03 };
04
05 let timerId = setInterval(timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?
Correct : A
Comprehensive and Detailed Explanation From JavaScript Knowledge:
The code:
let timerId = setInterval(timedFunction, 1000);
setInterval schedules timedFunction to run every 1000 ms.
It returns an interval ID (here stored in timerId), which is used to cancel the interval later.
To cancel:
Use clearInterval(timerId);
This is the standard browser (and Node.js) API:
let id = setInterval(fn, delay);
clearInterval(id); stops future executions of that interval.
Check other options:
B . removeInterval(timerId);
There is no removeInterval function in the standard JavaScript timer API.
C . removeInterval(timedFunction);
Again, no such function; and timers are cancelled by ID, not by the callback function reference.
D . clearInterval(timedFunction);
clearInterval expects the ID returned by setInterval, not the callback function.
Passing the function does not cancel the timer.
Therefore, the correct statement is:
Answe r: A
Study Guide / Concept Reference (no links):
Timer APIs: setInterval and clearInterval
Relationship between timer ID and cancellation
Difference between interval ID and callback function
Basic async timing patterns in JavaScript
Start a Discussions
Total 149 questions