JavaScript MCQs with answers Page - 144

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 will the output be?

Code:
let x = [1, 2, 3];
let y = x;
y.push(4);
console.log(x);
  • (A) [1, 2, 3]
  • (B) [1, 2, 3, 4]
  • (C) [4]
  • (D) undefined

A

Admin • 833K Points
Coach

Q. Which of the following is used to handle exceptions in JavaScript?

  • (A) try-catch
  • (B) do-except
  • (C) if-error
  • (D) error-handler

A

Admin • 833K Points
Coach

Q. What will be the output of this code?

Code:
console.log(1 == '1');
  • (A) false
  • (B) true
  • (C) undefined
  • (D) Error

A

Admin • 833K Points
Coach

Q. Which method adds an element at the end of an array?

  • (A) push()
  • (B) add()
  • (C) insert()
  • (D) append()

A

Admin • 833K Points
Coach

Q. What will this code print?

Code:
console.log(typeof undefined === typeof NULL);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) Error

A

Admin • 833K Points
Coach

Q. What will this function return?

Code:
function test() {
  return;
}
console.log(test());
  • (A) undefined
  • (B) null
  • (C) 0
  • (D) NaN

A

Admin • 833K Points
Coach

Q. What is the output of this code?

Code:
let name = 'MCQ';
name[0] = 'X';
console.log(name);
  • (A) XCQ
  • (B) MCQ
  • (C) undefined
  • (D) Error

A

Admin • 833K Points
Coach

Q. How do you convert a number to a string in JavaScript?

  • (A) num.toString()
  • (B) String(num)
  • (C) num + ''
  • (D) All of the above

A

Admin • 833K Points
Coach

Q. Which operator is used for optional chaining?

  • (A) ?.
  • (B) ?
  • (C) ??
  • (D) ->

A

Admin • 833K Points
Coach

Q. What is the result of this code?

Code:
console.log([] == 0);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) NaN

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