25 Essential JavaScript MCQ You Should Know — Codeymaze

CodeyMaze
2 min readJun 28, 2024

--

JavaScript is a high-level, versatile programming language widely used for creating interactive and dynamic content on websites. It is primarily a client-side language that runs in web browsers to enhance user interfaces and experiences, but it can also be used on the server side with environments like Node.js.

In this article, we will see some JavaScript MCQ questions with answers that helps you to prepare for your next interview.

Multiple Choice Questions with Answers

Q1. Which of the following is not a reserved word in JavaScript?

  • interface
  • throws
  • program
  • short

=> program

Q2. In JavaScript the x===y statement implies that

  • Both x and y are equal in value, type and reference address
  • Both are x and y are equal in value only
  • Both are equal in the value and data type
  • Both are not same at all

=> Both are equal in the value and data type

Q3. What will typeof NaN return?

  • number
  • NaN
  • undefined
  • object

=> number

Q4. What is the output of the following code?

console.log(typeof null);
  • null
  • undefined
  • object
  • number

=> object

Q5. What will NaN === NaN evaluate to in JavaScript?

  • True
  • False
  • Undefined
  • None of the above

=> False

Q6. Which of the following is not a valid JavaScript variable name?

  • _myVar
  • my-var
  • $myVar
  • myVar1

=> my-var

Q7. What is the output of the following code?

function test() {
console.log(this);
}
test();
  • undefined
  • null
  • Window object (in browsers)
  • test function

=> Window object (in browsers)

Q8. Which of the following method is used to merge two arrays into one?

  • arr1 + arr2
  • arr1.concat(arr2)
  • arr1.push(arr2)
  • arr1.merge(arr2)

=> arr1.concat(arr2)

Q9. What is the use of Promise.all method?

  • To run multiple promises sequentially
  • To wait until all promises are either resolved or rejected
  • To run multiple promises and return the result of the first resolved promise
  • To handle the first rejected promise only

=> To wait until all promises are either resolved or rejected

Q10. What will be the output of the following code?

let a = [1, 2, 3];
let b = a;
b.push(4);
console.log(a);
  • [1, 2, 3]
  • [1, 2, 3, 4]
  • undefined
  • error

=> [1, 2, 3, 4]

Originally published at https://codeymaze.com on June 28, 2024.

--

--

CodeyMaze
CodeyMaze

Written by CodeyMaze

Crafting Solutions Through Code & Words https://codeymaze.com Feel free to follow me :)

No responses yet