Back to articles
JavaScript Interview Traps That Destroy 90% of Candidates

JavaScript Interview Traps That Destroy 90% of Candidates

via Dev.to WebdevEbenezer

JavaScript Interview Puzzle #1 The this Keyword Trap That Confuses Even Experienced Developers Most developers think they understand JavaScript.And to be fair — most of the time they do.But every now and then, JavaScript throws a small puzzle that quietly exposes a gap in our understanding. Today’s puzzle is one of those.It looks harmless.It looks simple.But it has confused thousands of developers during interviews. Let’s see if it tricks you too. The Puzzle Look at the code below carefully. What do you think it will print? const user = { name : " Ebenezer " , greet : function () { console . log ( this . name ); } }; const greetFunc = user . greet ; greetFunc (); Take a moment. Don't rush to the answer. What do you think the output will be? Most people say: Ebenezer But that is not what JavaScript prints. The actual output is: undefined Wait. Why? The object clearly has a name. So why did JavaScript forget it? To understand this puzzle, we need to talk about one of JavaScript’s most mi

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles