DK
Q3.) function makeUser() { return { name: "John", ref: this }; } let user = makeUser(); alert( user.ref.name ) output will not be an error. It will return an empty string. As window object has a name property and its value is an empty string let user={ name:'john', ref:this } console.log(user.name)->john console.log(user.ref)->window object console.log(user.ref.name)->empty string
CommentArticleSep 4, 2022Javascript Interview Questions ( 'this' Keyword ) - Output Based, Scope, Implicit Binding, etc