JavaScript MCQs with answers Page - 145

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. How do you write a conditional statement for executing code if 'x' is greater than 5?

  • (A) if x > 5
  • (B) if (x > 5)
  • (C) if x > 5 then
  • (D) if (x > 5) then

A

Admin • 833K Points
Coach

Q. What will be logged?

Code:
let a = 1;
let b = a++;
console.log(b);
  • (A) 2
  • (B) 1
  • (C) undefined
  • (D) NaN

A

Admin • 833K Points
Coach

Q. Which object method returns an array of a given object's property names?

  • (A) Object.keys()
  • (B) Object.names()
  • (C) Object.get()
  • (D) Object.entries()

A

Admin • 833K Points
Coach

Q. What will be the result?

Code:
typeof function(){};
  • (A) function
  • (B) object
  • (C) undefined
  • (D) function()

A

Admin • 833K Points
Coach

Q. Which operator is used to merge two arrays?

  • (A) +
  • (B) &
  • (C) concat()
  • (D) merge()

A

Admin • 833K Points
Coach

Q. What will this return?

Code:
[1, 2, 3].includes(2);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) NaN

A

Admin • 833K Points
Coach

Q. Which of the following is a falsy value?

  • (A) 0
  • (B) null
  • (C) undefined
  • (D) All of the above

A

Admin • 833K Points
Coach

Q. What is the value of x?

Code:
let x = '5';
x = +x;
  • (A) '5'
  • (B) 5
  • (C) NaN
  • (D) undefined

A

Admin • 833K Points
Coach

Q. What does this expression return?

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

A

Admin • 833K Points
Coach

Q. What is a Promise in JavaScript?

  • (A) A function that never runs
  • (B) A placeholder for a future value
  • (C) A data type
  • (D) An error object

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ