ANSWERS | 2025/2026 LATEST UPDATE | ALREADY GRADED A+
What is the difference between JSON.parse and JSON.stringify? JSON.parse - parse a JSON
string and converts JavaScript value or object.
JSON.stringify - converts JavaScript object or value to JSON String.
What is the log output for the following code?
const json = '{"result":true, "count":42}';
const obj = JSON.parse(json);
console.log(obj.result); ANSWER:
true
What is the log output for the following code?
console.log(JSON.stringify([new Number(3), new String('false'), new
Boolean(false)])); ANSWER:
A String with the value of "[3,"false",false]"
Which of the following is not an attribute of Object.defineProperty()?
A. Configurable
B. Stateful
C. Enumerable
D. Writeable ANSWER:
,B. Stateful
Additional Info:
Configurable: the ability to redefine property descriptors (ie enumerable or configurable). If
configurable is set to false for a given property, you can NOT delete the property.
Enumerable: ability to iterate over a given property with a for...in loop. Also impacts
Object.keys() and JSON serialize properties.
Writeable: allows a value of an associated property to be changed.
What will be the log output for the following?
let emp = {
fName: 'Test',
lName: 'User',
get fullName(){
return fName + ' ' + lName;
},
set fullName(str){
var nameParts = str.split(' ');
this.fName = nameParts[0];
this.lName = nameParts[1];
}
}
emp.fullName ='John Smith';
,console.log(emp.fName);
A. Test
B. Undefined
C. John
D. TypeError ANSWER:
C. John
What is the difference between a function's prototype and an object's prototype? A
function's prototype is the object instance that will become the prototype for objects created
using this function as a constructor.
An object's prototype is the object instance from which the object is inherited.
What will be the output log of the following code:
function Person (fName, lName) {
this.fName = fName;
this.lName = lName;
}
Person.prototype.age = 29;
let jim = new Person('Jim', 'Smith');
jim.age = 18;
, console.log(jim.age);
console.log(jim.__proto___.age); ANSWER:
18
29
Additional Info:
jim.age actually creates a new property on the jim object while the .__proto__.age is in
reference to the parent object in which jim was created from.
If jim.age was NOT set, then the values would be 29 and 29. JavaScript looks at the object
property first and then the prototype.
What will be the output logs of the following code:
function Person (fName, lName) {
this.fName = fName;
this.lName = lName;
}
Person.prototype.age = 29;
let jim = new Person('Jim', 'Smith');
let sofia = new Person('Sofia', 'Smith');
console.log(jim.__proto__.age);
console.log(sofia.age);