Skip to main content

JavaScript

Single-threaded, event-driven, and everywhere. Master these concepts and you’re ready for any JS interview.

Topics

Core characteristics

PropertyValue
TypingDynamic, weakly typed
ParadigmMulti-paradigm (OOP, functional, event-driven)
ExecutionSingle-threaded with event loop
ScopeLexical (static)
Most Asked Topics
Closures, the event loop, prototypal inheritance, and this binding appear in nearly every JS interview. Know these cold.

Quick reference

// var vs let vs const
var x = 1;    // function-scoped, hoisted
let y = 2;    // block-scoped, not hoisted (TDZ)
const z = 3;  // block-scoped, cannot be reassigned

// Type coercion gotchas
console.log(0 == false);   // true  (loose equality)
console.log(0 === false);  // false (strict equality)

// Falsy values: false, 0, "", null, undefined, NaN
// Truthy: everything else (including [] and {})
💡 Interview Tip
Always use === over ==. Explain why when asked — type coercion in JS is a common trick question area.

Common interview questions

== performs type coercion before comparing. === (strict equality) compares both value and type without coercion. Always prefer === to avoid unexpected behavior.
1 == "1"   // true  (string coerced to number)
1 === "1"  // false
null == undefined   // true
null === undefined  // false
JavaScript moves variable and function declarations to the top of their scope before execution. var declarations are hoisted and initialized to undefined. let/const are hoisted but stay in the Temporal Dead Zone (TDZ) until the declaration is reached. Function declarations are fully hoisted (body included).
console.log(a); // undefined (hoisted)
var a = 5;

console.log(b); // ReferenceError
let b = 5;
There are exactly 6 falsy values: false, 0, "" (empty string), null, undefined, and NaN. Everything else is truthy — including [], {}, and "false".