Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
function person()
{
this.name = ‘rahul’;
}
function obj()
{
obj.call(this)
}
obj.prototype = Object.create(person.prototype);
const app = new obj();
console.log(app.name);

What will be the output of the following JavaScript code?
function person()
{
this.name = ‘rahul’;
}
function obj()
{
obj.call(this)
}
obj.prototype = Object.create(person.prototype);
const app = new obj();
console.log(app.name);
a) undefined
b) runtime error
c) compilation error
d) rahul

Answer: d
Explanation: Object.create() method is used to create a new object with the specified properties. This is another way of creating a new object using specified object type. The particular function accepts two values as an argument.

Join The Discussion