Interview Q&A / JavaScript
JavaScript interview questions
Closures, the event loop, this, promises and the core language questions every frontend round asks.
Prefer rapid revision? Practise JavaScript short interview answers →
- What are prototypes in JavaScript, and how does prototypal inheritance work?
Every object has a hidden link to another object called its prototype. When you read a property that the object does not have, JavaScript looks it up along this prototype chain. Classes are syntax built on top of this: methods live on the prototype and are shared by all instances.
AdvancedIn-depth3 min read - What is this after calling bind twice on the same function?
The first bind wins. A bound function's this is permanent, so calling bind again on it, or call and apply, cannot change it. Only extra preset arguments from the second bind take effect.
AdvancedQuick answer1 min read - Why does [] == ![] return true in JavaScript?
![] is false because an array is truthy. Then [] == false converts both sides to numbers: [] becomes "" then 0, and false becomes 0, so 0 == 0 is true.
AdvancedQuick answer1 min read