Exam JS-Dev-101 Topic 1 Question 17 Discussion

Actual exam question for Salesforce's JS-Dev-101 exam
Question #: 17
Topic #: 1
Corrected code:
function Person() {
this.firstName = "John";
}
Person.prototype = {
job: x => "Developer"
};
const myFather = new Person();
const result = myFather.firstName + " " + myFather.job();
What is the value of result after line 10 executes?

Suggested Answer: A Vote an answer

The verified answer is A.
This constructor function runs when new Person() is called:
function Person() {
this.firstName = "John";
}
So this line:
const myFather = new Person();
creates an object like this:
{
firstName: "John"
}
Then the prototype is assigned a method named job:
Person.prototype = {
job: x => "Developer"
};
Because myFather is created from Person, it can access properties and methods from Person.prototype.
So:
myFather.firstName
returns:
"John"
And:
myFather.job()
returns:
"Developer"
Therefore:
const result = myFather.firstName + " " + myFather.job();
becomes:
const result = "John" + " " + "Developer";
Final value:
"John Developer"
Option B is incorrect because job() returns "Developer", not undefined.
Option C is incorrect because job exists on Person.prototype, so it is callable.
Option D is incorrect because firstName is assigned inside the constructor.
Therefore, the verified answer is A.

by Evelyn at Jul 22, 2026, 01:17 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10