DEV Community

Emma Bostian ✨
Emma Bostian ✨

Posted on

What’s your favorite JS interview question?

What’s your favorite interview question to ask a candidate?

Latest comments (40)

Collapse
 
vupadhayayx86 profile image
vupadhayayx86

setTimeout(()=>console.log("Hello4"),1004)
setTimeout(()=>console.log("Hello3"),1003)
setTimeout(()=>console.log("Hello2"),1002)
setTimeout(()=>console.log("Hello1"),1001)
setTimeout(()=>console.log("Hello0"),1000)

or
for(let i=0;i<5;i++){
setTimeout(()=>console.log("Hello" +i),1000*1)
}

Both code will produce same result!

Collapse
 
buzzfair profile image
Guin White • Edited

I'm new to JS, and I'm pretty clear on why this logs 10 to the console, but I'm not understanding why it logs it 10 times. Can someone please explain this to a noob?

PS - apologies for reactivating an older thread, but this code actually came up in another context, and when I searched I found this discussion. Thanks for understanding.

Collapse
 
pinotattari profile image
Riccardo Bernardini

I am not a JS expert, but... TAB == 0 ?!? 😲

Collapse
 
not_jffrydsr profile image
@nobody

What's difference between this


kung.prototype.fu = function() { juli.do_the_thing(); 
}

and this


class kung {

  fu() { 
   do_the_thing(juli);
    }
 }
Collapse
 
johnpaulada profile image
John Paul Ada

Create a non-brute force autocomplete function in JavaScript. 😎

Collapse
 
pawail profile image
Pawail A. Qaisar

I know this might sound a bit ridiculous, but...

'When was the first time you touched a computer?'

'And when was the first time a computer touched you?'

No pun intended! :)

Collapse
 
lexlohr profile image
Alex Lohr

What's your favorite addition to ECMAscript?

Collapse
 
tnacioustyson profile image
Tyson Williams

Any that I know and get right. 😅

Collapse
 
ufocoder profile image
Sergey Ivanov

Because answer on this question will discover what answerer know about:

  • Scopes
  • Closures
  • How event loop works in the browser

Some comments may only be visible to logged-in visitors. Sign in to view all comments.