JavaScript MCQs with answers Page - 147

Here, you will find a collection of MCQ questions on JavaScript. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833K Points
Coach

Q. What is the purpose of the isNaN() function?

  • (A) Checks if a value is NaN
  • (B) Checks if a value is not a number
  • (C) Checks if a value is null
  • (D) Both a and b

A

Admin • 833K Points
Coach

Q. What does this function return?

Code:
function test() {
  return typeof arguments;
}
  • (A) "arguments"
  • (B) "array"
  • (C) "object"
  • (D) "function"

A

Admin • 833K Points
Coach

Q. Which one is not a primitive data type in JavaScript?

  • (A) string
  • (B) object
  • (C) number
  • (D) boolean

A

Admin • 833K Points
Coach

Q. What is the output of this expression?

Code:
console.log('5' + 1);
  • (A) 6
  • (B) '51'
  • (C) undefined
  • (D) NaN

A

Admin • 833K Points
Coach

Q. How do you write an arrow function that returns 10?

  • (A) () => return 10;
  • (B) () => 10
  • (C) => 10
  • (D) function => 10

A

Admin • 833K Points
Coach

Q. What does the rest operator do?

  • (A) Copies arrays
  • (B) Spreads arrays
  • (C) Collects remaining arguments
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. What will this log?

Code:
console.log(typeof NaN);
  • (A) "NaN"
  • (B) "number"
  • (C) "undefined"
  • (D) "object"

A

Admin • 833K Points
Coach

Q. Which method can be used to iterate over an array?

  • (A) forEach()
  • (B) map()
  • (C) for...of
  • (D) All of the above

A

Admin • 833K Points
Coach

Q. What does this code do?

Code:
setTimeout(() => console.log('Hello'), 0);
  • (A) Logs immediately
  • (B) Logs after 0 ms delay
  • (C) Never logs
  • (D) Throws error

A

Admin • 833K Points
Coach

Q. What is the result of this?

Code:
false == '0';
  • (A) true
  • (B) false
  • (C) undefined
  • (D) Error