I have the following code
function Person(name){
console.log(this);
this.firstname=name;
}
var sam=new Person("Sam");
console.log(sam);
Output is - Response
When a new Object is created, initially this should point to an empty object. Why it has the updated response?
Output is - Response- how can the output be "Response" ... surely it's a "Person" objectResponseis a hyperlink showing that the object firstname has been console logged before it has been set in the code.console.log(JSON.stringify(this))andconsole.log(JSON.stringify(sam));to get a true snapshot