🚨 JavaScript Interview Question What will be the output? const obj = { name: "Frontend", greet: function () { console.log(this.name); } }; const greet = obj.greet; greet(); greet.call(obj); greet.bind(obj)(); This question tests understanding of: • this binding • call() • bind() • Function invocation context Many developers expect all three calls to behave the same. But JavaScript handles this differently depending on how the function is invoked. What do you think the output will be? #JavaScript #FrontendInterview #ReactJS #FrontendDeveloper #JavaScriptConcepts #ProductBasedCompany
Frontend Frontend function() { Console. Log(this.name)} Is this correct Suman Yadav
greet() undefined (or error in strict mode) greet.call(obj) Frontend greet.bind(obj)() Frontend
undefined Frontend Frontend
Undefined Frontend Frontend
Hint: call() invokes the function immediately with a specified this, while bind() returns a new function with this permanently bound.