PrepAhead
Start free
← All posts

JavaScript fundamentals quiz (10 questions)

June 6, 2026

  • JavaScript
  • Frontend
  • Fundamentals

These questions cover the JavaScript fundamentals that show up repeatedly in early frontend interviews: truthiness, equality, object and array basics, and the language behaviors that can trip people up in production code.

If this set feels easy on syntax but harder on reasoning, the next good step is closures and scope. That is where many interviewers start testing whether you understand how JavaScript really behaves at runtime.

Question 1

Which value is truthy in JavaScript?

Pick an answer to see if you are correct
Reveal answer

Answer

[] - An empty array is truthy in JavaScript.

Explanation

JavaScript treats all objects as truthy, and arrays are objects. By contrast, 0, the empty string, null, undefined, false, and NaN are falsy.

Common interview notes

A common follow-up is why this matters in conditional rendering and form-validation code.

Question 2

What is the result of typeof null?

Pick an answer to see if you are correct
Reveal answer

Answer

object - typeof null returns "object".

Explanation

This is a long-standing historical quirk in JavaScript. It often comes up in interviews because it shows whether the candidate knows to avoid relying on typeof alone for null checks.

Common interview notes

Strong answers mention using value === null when you need an exact null check.

Question 3

You need to compare two values without type coercion. Which operator is the best default choice?

Pick an answer to see if you are correct
Reveal answer

Answer

=== - === is the best default choice because it compares both value and type.

Explanation

The strict equality operator avoids JavaScript's coercion rules, which can make == comparisons surprising. In production code and interviews, === is usually the safer default.

Example

5 === "5" // false
5 == "5"  // true

Common interview notes

Interviewers often ask for one or two surprising == examples to test whether you understand coercion.

Question 4

Which method creates a new array without mutating the original one?

Pick an answer to see if you are correct
Reveal answer

Answer

map() - map creates a new array and leaves the original array unchanged.

Explanation

map transforms each element and returns a fresh array. push and pop mutate the original array, and splice also changes the array in place.

Common interview notes

A useful follow-up is the difference between map, forEach, and filter.

Question 5

What is the most accurate description of const in JavaScript?

Pick an answer to see if you are correct
Reveal answer

Answer

It prevents reassignment of the binding - const prevents reassignment of the variable binding.

Explanation

If a const variable points to an object or array, that object can still be mutated unless you explicitly freeze or clone it. const is about the binding, not deep immutability.

Common interview notes

This question often leads into a discussion of reference values versus primitive values.

Question 6

Which expression correctly checks whether an array contains the value 3?

Pick an answer to see if you are correct
Reveal answer

Answer

arr.includes(3) - arr.includes(3) is the correct built-in array membership check.

Explanation

includes returns a boolean indicating whether the value exists in the array. find is for retrieving a matching element by predicate, not for direct membership checks by value.

Example

const ids = [1, 2, 3];
ids.includes(3); // true

Common interview notes

A common follow-up is the difference between includes and indexOf, especially around readability and NaN handling.

Question 7

What does Object.keys(user) return?

Pick an answer to see if you are correct
Reveal answer

Answer

An array of the object's own enumerable property names - Object.keys returns an array of the object's own enumerable property names.

Explanation

It is commonly used when you need to iterate over object properties, count them, or transform them. It returns names only, not values or entries.

Common interview notes

Strong candidates often mention Object.values and Object.entries as related tools.

Question 8

Which statement about functions in JavaScript is correct?

Pick an answer to see if you are correct
Reveal answer

Answer

Functions can be passed as arguments and returned from other functions - Functions are first-class values and can be passed around like other values.

Explanation

This property is central to callbacks, array methods, event handlers, higher-order functions, and closures. It is one of the reasons JavaScript code often relies heavily on function composition.

Common interview notes

A good follow-up is to ask the candidate for a simple higher-order function example from real UI or API code.

Question 9

Which value does Array.isArray({}) return?

Pick an answer to see if you are correct
Reveal answer

Answer

false - Array.isArray({}) returns false because a plain object is not an array.

Explanation

Array.isArray is the recommended built-in check for arrays because typeof returns "object" for both arrays and plain objects. That distinction comes up often in data-validation and rendering logic.

Common interview notes

A common interview angle is why Array.isArray is safer than instanceof across realms.

Question 10

You need to copy properties from one object into a new object without mutating the original. Which syntax is the clearest default?

Pick an answer to see if you are correct
Reveal answer

Answer

{ ...source } - The object spread syntax creates a new object with the copied enumerable properties.

Explanation

Object spread is concise and readable for shallow copies. It does not create a deep copy, so nested objects are still shared by reference unless you clone them separately.

Example

const updatedUser = { ...user, role: "admin" };

Common interview notes

Interviewers often follow up by asking what "shallow copy" means and where shared nested references can still cause bugs.

Full answer key

Review every answer in one place, with explanations and interview tips below.

1. Which value is truthy in JavaScript?

Answer summary

[] — An empty array is truthy in JavaScript.

JavaScript treats all objects as truthy, and arrays are objects. By contrast, 0, the empty string, null, undefined, false, and NaN are falsy.

Interview tip: A common follow-up is why this matters in conditional rendering and form-validation code.

2. What is the result of typeof null?

Answer summary

object — typeof null returns "object".

This is a long-standing historical quirk in JavaScript. It often comes up in interviews because it shows whether the candidate knows to avoid relying on typeof alone for null checks.

Interview tip: Strong answers mention using value === null when you need an exact null check.

3. You need to compare two values without type coercion. Which operator is the best default choice?

Answer summary

=== — === is the best default choice because it compares both value and type.

The strict equality operator avoids JavaScript's coercion rules, which can make == comparisons surprising. In production code and interviews, === is usually the safer default.

5 === "5" // false
5 == "5"  // true

Interview tip: Interviewers often ask for one or two surprising == examples to test whether you understand coercion.

4. Which method creates a new array without mutating the original one?

Answer summary

map() — map creates a new array and leaves the original array unchanged.

map transforms each element and returns a fresh array. push and pop mutate the original array, and splice also changes the array in place.

Interview tip: A useful follow-up is the difference between map, forEach, and filter.

5. What is the most accurate description of const in JavaScript?

Answer summary

It prevents reassignment of the binding — const prevents reassignment of the variable binding.

If a const variable points to an object or array, that object can still be mutated unless you explicitly freeze or clone it. const is about the binding, not deep immutability.

Interview tip: This question often leads into a discussion of reference values versus primitive values.

6. Which expression correctly checks whether an array contains the value 3?

Answer summary

arr.includes(3) — arr.includes(3) is the correct built-in array membership check.

includes returns a boolean indicating whether the value exists in the array. find is for retrieving a matching element by predicate, not for direct membership checks by value.

const ids = [1, 2, 3];
ids.includes(3); // true

Interview tip: A common follow-up is the difference between includes and indexOf, especially around readability and NaN handling.

7. What does Object.keys(user) return?

Answer summary

An array of the object's own enumerable property names — Object.keys returns an array of the object's own enumerable property names.

It is commonly used when you need to iterate over object properties, count them, or transform them. It returns names only, not values or entries.

Interview tip: Strong candidates often mention Object.values and Object.entries as related tools.

8. Which statement about functions in JavaScript is correct?

Answer summary

Functions can be passed as arguments and returned from other functions — Functions are first-class values and can be passed around like other values.

This property is central to callbacks, array methods, event handlers, higher-order functions, and closures. It is one of the reasons JavaScript code often relies heavily on function composition.

Interview tip: A good follow-up is to ask the candidate for a simple higher-order function example from real UI or API code.

9. Which value does Array.isArray({}) return?

Answer summary

false — Array.isArray({}) returns false because a plain object is not an array.

Array.isArray is the recommended built-in check for arrays because typeof returns "object" for both arrays and plain objects. That distinction comes up often in data-validation and rendering logic.

Interview tip: A common interview angle is why Array.isArray is safer than instanceof across realms.

10. You need to copy properties from one object into a new object without mutating the original. Which syntax is the clearest default?

Answer summary

{ ...source } — The object spread syntax creates a new object with the copied enumerable properties.

Object spread is concise and readable for shallow copies. It does not create a deep copy, so nested objects are still shared by reference unless you clone them separately.

const updatedUser = { ...user, role: "admin" };

Interview tip: Interviewers often follow up by asking what "shallow copy" means and where shared nested references can still cause bugs.

Try each question on your own, then open "Reveal answer" for the full write-up. For tailored practice and Check feedback on open-ended responses, use PrepAhead in the app - not on blog pages.