INTERVIEW QUESTIONS

JavaScript Interview Questions

Practice JavaScript prompts by theme and build clearer interview answers.

Practice by topicRole and skill lensesClear answer prompts

Showing 52 practice prompts

✦

JAVASCRIPT

What is the difference between var, let, and const in JavaScript?

'var' is function-scoped (or globally scoped), allows re-declaration, and is hoisted with an initial value of undefined. 'let' and 'const' are block-scoped, cannot be re-declared in the same scope, and are hoisted into a Temporal Dead Zone (TDZ) where accessing them before initialization throws a ReferenceError. 'const' also prevents reassignment of the variable binding (though object properties remain mutable).
CompanyGoogle◦ Variables & Scope
✦

JAVASCRIPT

What is a closure in JavaScript and how does lexical scoping work?

A closure is a function that retains access to variables from its outer (enclosing) lexical scope, even after the outer function has returned and exited the call stack. Lexical scoping means variable resolution is determined by the physical placement of functions and blocks in the source code at author time.
CompanyMeta◦ Closures
✦

JAVASCRIPT

What is hoisting in JavaScript?

Hoisting is the behavior of the JavaScript engine during the creation phase of an execution context, where variable and function declarations are moved to the top of their containing scope before code execution. Function declarations are hoisted with their complete definition, var is hoisted as undefined, and let/const are placed in the Temporal Dead Zone.
CompanyAmazon◦ Execution Context
✦

JAVASCRIPT

What are the primary primitive data types in JavaScript?

JavaScript has 7 primitive types: string, number, bigint, boolean, undefined, symbol, and null. All primitives are immutable and passed by value. Everything else in JavaScript is an Object (including arrays, functions, and regexes), which is mutable and passed by reference.
CompanyApple◦ Data Types
✦

JAVASCRIPT

What is the difference between null and undefined?

'undefined' indicates that a variable has been declared but has not yet been assigned a value, or that a function returned without a value. 'null' represents the intentional absence of any object value and is explicitly assigned by developers to represent 'empty' or 'non-existent'.
CompanyNetflix◦ Data Types
…

Your next interview is closer than you think.

Practice smarter and land better opportunities.

✓ Start with the free plan✓ No credit card✓ Cancel anytime
Start preparing free