JavaScript Interview

JavaScript Fundamentals, Types, Scope & Functions

JavaScript interview questions covering language fundamentals, ECMAScript, data types, scope, hoisting, coercion, functions, parameters, spread and destructuring.

25 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

25 Results
1
JuniorBeginner

What is JavaScript?

JavaScript is a high-level, dynamically typed programming language primarily used to make web pages interactive. It runs natively in web browsers and can also run outside the browser through environments such as Node.js.

2
JuniorBeginner

What is the difference between JavaScript and ECMAScript?

ECMAScript is the standardized language specification on which JavaScript is based. It defines the syntax, types, operators, objects, statements, functions, and other core language behavior.

3
JuniorBeginner

What are the primitive data types in JavaScript?

JavaScript has seven primitive data types: string, number, bigint, boolean, undefined, symbol, and null. Primitive values are not objects and are immutable, meaning the primitive value itself cannot be changed in place.

4
JuniorBeginner

What is the difference between primitive and reference values in JavaScript?

Primitive values such as strings, numbers, and booleans are copied as values. Objects, arrays, and functions are reference types in practical JavaScript terminology: a variable stores a reference to the object rather than embedding a separate copy of the entire object.

5
JuniorBeginner

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

var is function-scoped, can be redeclared in the same scope, and its declaration is hoisted and initialized with undefined. let and const are block-scoped and cannot be redeclared in the same block.

6
JuniorBeginner

What is scope in JavaScript?

Scope determines where a variable or function can be accessed. JavaScript commonly has global scope, function scope, block scope, and module scope.

7
JuniorBeginner

What is lexical scope in JavaScript?

Lexical scope means that variable accessibility is determined by where functions and blocks are written in the source code. An inner function can access variables from its own scope and from its enclosing scopes.

8
JuniorBeginner

What is hoisting in JavaScript?

Hoisting describes how JavaScript processes declarations before executing code in a scope. Function declarations can generally be called before their textual declaration. var declarations are hoisted and initialized with undefined.

9
JuniorBeginner

What is the Temporal Dead Zone (TDZ)?

The Temporal Dead Zone is the period between entering a block scope and executing the declaration of a let, const, or class binding. During this period, the binding exists but cannot be accessed.

10
JuniorBeginner

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

The == operator performs loose equality comparison and may convert operands to compatible types before comparing them. The === operator performs strict equality and does not perform this type coercion.

11
JuniorBeginner

What is type coercion in JavaScript?

Type coercion is the conversion of a value from one type to another. JavaScript can perform implicit coercion automatically during certain operations, or developers can perform explicit conversion using functions such as Number, String, and Boolean.

12
JuniorBeginner

What are truthy and falsy values in JavaScript?

In a Boolean context, JavaScript converts values to true or false. Falsy values include false, 0, -0, 0n, an empty string, null, undefined, and NaN. Most other values are truthy, including empty arrays and empty objects.

13
JuniorBeginner

What is null, and how is it different from undefined?

undefined usually represents a value that has not been assigned or is missing, while null is normally used intentionally to represent the absence of a value.

14
JuniorBeginner

What is NaN in JavaScript?

NaN means Not-a-Number. It is a special numeric value representing an invalid or unrepresentable numeric result, such as trying to convert non-numeric text to a number.

15
JuniorBeginner

What is the difference between Number.isNaN() and isNaN()?

Number.isNaN(value) returns true only when the supplied value is actually the numeric NaN value. The global isNaN(value) first attempts numeric coercion and then tests the result.

16
JuniorBeginner

What are template literals in JavaScript?

Template literals are string literals written with backticks. They support embedded expressions through ${...}, multi-line strings, and tagged template functionality.

17
JuniorBeginner

What is a function declaration in JavaScript?

A function declaration defines a named function using the function keyword. Function declarations are hoisted in a way that normally allows them to be called before the declaration appears in the source code.

18
JuniorBeginner

What is a function expression in JavaScript?

A function expression creates a function as part of an expression, commonly by assigning it to a variable. The function may be anonymous or named.

19
JuniorBeginner

What is the difference between a function declaration and a function expression?

A function declaration is declared directly with the function keyword and a name, while a function expression creates a function as a value inside an expression, often assigned to a variable.

20
JuniorBeginner

What is an arrow function in JavaScript?

An arrow function is a compact function syntax introduced in ES6. It is especially convenient for callbacks and short functional operations.

21
JuniorBeginner

How does this behave differently in arrow functions and regular functions?

A regular function's this value generally depends on how the function is called. An arrow function does not define its own this; instead, it captures this lexically from the surrounding scope.

22
JuniorBeginner

What are default parameters in JavaScript?

Default parameters allow a function parameter to receive a predefined value when the corresponding argument is omitted or explicitly passed as undefined.

23
JuniorBeginner

What are rest parameters in JavaScript?

Rest parameter syntax collects zero or more remaining arguments into a real array. It is written with three dots before the final parameter name.

24
JuniorBeginner

What is the spread syntax in JavaScript?

Spread syntax uses three dots to expand an iterable into individual elements or to copy enumerable properties into a new object. It is commonly used with arrays, function arguments, and object literals.

25
JuniorBeginner

What is destructuring in JavaScript?

Destructuring is syntax for extracting values from arrays or properties from objects into variables. It supports defaults, renaming, nested patterns, and rest elements.