React / Next.js

JavaScript Essentials

Variables (let/const/var), types, closures, this, arrow functions, destructuring, spread/rest

25 interview questionsยท
Junior
1

What is the main difference between let and var?

Answer

let declares a block-scoped variable, meaning it only exists within the block where it's defined (between braces). var has function scope, which can cause unexpected bugs as the variable is accessible throughout the entire function. Using let by default prevents hoisting issues and variable leaks in loops or conditionals.

2

Which declaration to use for a value that won't change?

Answer

const allows declaring a constant whose reference cannot be reassigned. This improves code readability by clearly indicating intent and prevents accidental modifications. Note that for objects and arrays, const only prevents reassigning the reference, not modifying the content. It's the best practice for declaring immutable values.

3

Which JavaScript data type is not primitive?

Answer

Objects are the only non-primitive type in JavaScript. Primitive types include string, number, boolean, null, undefined, symbol and bigint. Objects are stored by reference in memory, while primitives are stored by value. This means modifying an object affects all references to it, whereas copying a primitive creates an independent new value.

4

What does typeof null return in JavaScript?

5

What is the difference between == and ===?

+22 interview questions

Master React / Next.js for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free