Salesforce JavaScript Developer Practice Exam

1 / 400

What is the result of `console.log(jim.__proto__.age);` after defining a Person prototype property?

29

To understand the correct answer, it's important to look at how JavaScript's prototypal inheritance works and how properties are accessed on objects.

In JavaScript, when an object is created, it can inherit properties from its prototype. When you define a property on the prototype of a constructor function (like Person), all instances of that object can access that property through their prototype chain.

If we assume that the Person prototype has an `age` property set to 29, then any instance of Person, such as `jim`, will be able to access this property through `jim.__proto__`. The `__proto__` property refers to the prototype of the object (`jim` in this case). Hence, when `console.log(jim.__proto__.age);` is executed, it will look up the inheritance chain and find the `age` property defined on the Person prototype, returning its value, which is 29.

Given this context, if the prototype was indeed set up properly to contain an `age` property equal to 29, then logging `jim.__proto__.age` would correctly output 29.

Get further explanation with Examzify DeepDiveBeta

18

TypeError

undefined

Next Question
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy