Top 500 Javascript MCQ Interview Questions

Question 451: What will console.log(typeof []); output?
Answer: B) 'object'
Question 452: What is the output of console.log('Hello' + 5);?
Answer: A) 'Hello5'
Question 453: Which of the following is a primitive data type in JavaScript?
Answer: C) String
Question 454: What will console.log(1 + '1' - 1); output?
Answer: A) 1
Question 455: What does the "use strict" directive do in JavaScript?
Answer: B) It enables strict mode which helps to write secure JavaScript.
Question 456: What is the output of console.log('abc'.length);?
Answer: A) 3
Question 457: What will console.log(!!'Hello'); output?
Answer: A) true
Question 458: What is the output of console.log(NaN === NaN);?
Answer: B) false
Question 459: What is the result of the following operation: '5' + 5 - 5?
Answer: A) 5
Question 460: Which function can be used to parse a JSON string?
Answer: A) JSON.parse()
Question 461: What does the Array.isArray() method do?
Answer: A) Checks if the object is an array
Question 462: What is the output of console.log('1' + -1);?
Answer: C) '0'
Question 463: Which of the following is used to declare a variable in JavaScript?
Answer: D) All of the above
Question 464: What is the output of console.log('Hello' + 'World');?
Answer: A) HelloWorld
Question 465: Which method can be used to convert a string to a number?
Answer: D) All of the above
Question 466: What will console.log(0 === '0'); output?
Answer: B) false
Question 467: Which operator is used to compare two values for equality in JavaScript?
Answer: D) Both B and C
Question 468: What is the output of console.log(undefined == null);?
Answer: A) true
Question 469: What is the result of the following operation: [] + {}?
Answer: A) '[object Object]'
Question 470: Which built-in method combines the text of two strings and returns a new string?
Answer: B) concat()
Question 471: What is the output of console.log(1 == '1');?
Answer: A) true
Question 472: Which of the following is NOT a JavaScript data type?
Answer: D) Character
Question 473: What will console.log(typeof NaN); output?
Answer: A) 'number'
Question 474: Which keyword is used to define a variable in JavaScript?
Answer: D) All of the above
Question 475: What is the output of console.log(1 + '1');?
Answer: B) '11'
Question 476: Which operator is used for division in JavaScript?
Answer: A) /
Question 477: What is the result of the following operation: 3 + 2 + '1'?
Answer: A) 51
Question 478: Which of the following is used to create an array in JavaScript?
Answer: A) []
Question 479: What will be the output of console.log(1 + '2' - '1');?
Answer: A) 2
Question 480: Which function is used to find the length of a string in JavaScript?
Answer: C) str.length
Question 481: What will be the output of console.log(2 ** 3);?
Answer: B) 8
Question 482: What does the 'this' keyword refer to in JavaScript?
Answer: C) The current object
Question 483: Which method is used to convert a JSON string into a JavaScript object?
Answer: B) JSON.parse()
Question 484: Which operator is used to check for both value and type in JavaScript?
Answer: C) ===
Question 485: What will be the output of console.log(false + 1);?
Answer: A) 1
Question 486: Which of the following is a way to create an object in JavaScript?
Answer: C) Both A and B
Question 487: What does the Array.isArray() method do?
Answer: A) Checks if an object is an array
Question 488: What is the output of console.log(0.1 + 0.2 == 0.3);?
Answer: B) false
Question 489: Which of the following is a valid way to define a function in JavaScript?
Answer: C) Both A and B
Question 490: What is the purpose of the 'use strict' statement in JavaScript?
Answer: A) To enable strict mode
Question 491: Which method is used to remove the last element from an array in JavaScript?
Answer: A) pop()
Question 492: What is the result of the following code: console.log(typeof NaN);?
Answer: A) 'number'
Question 493: Which of the following is used to prevent the default action of an event in JavaScript?
Answer: A) event.preventDefault()
Question 494: What will be the output of console.log(typeof null);?
Answer: B) 'object'
Question 495: Which method is used to add one or more elements to the end of an array in JavaScript?
Answer: A) push()
Question 496: What does NaN stand for in JavaScript?
Answer: A) Not a Number
Question 497: Which method is used to combine two or more arrays in JavaScript?
Answer: A) concat()
Question 498: Which of the following is NOT a primitive data type in JavaScript?
Answer: C) Object
Question 499: What will be the output of the following code: console.log('5' + 3);?
Answer: A) '53'
Question 500: What does the 'window' object represent in JavaScript?
Answer: D) All of the above

Showing 451-500 of 500 questions

Contact Tech Spakes Training