Top 500 Javascript MCQ Interview Questions

Question 51: Which of the following methods can be used to remove an element from an array?
Answer: D) All of the above
Question 52: What is the output of console.log('2' + 2);?
Answer: B) 22
Question 53: What does the filter() method do in JavaScript?
Answer: A) Returns a new array with elements that pass a test
Question 54: Which method is used to convert a string to lowercase in JavaScript?
Answer: A) toLowerCase()
Question 55: What will console.log([1, 2, 3].map(x => x * 2)); output?
Answer: A) [2, 4, 6]
Question 56: Which of the following is true about let and var?
Answer: A) let is block-scoped, while var is function-scoped
Question 57: What is the output of console.log(5 == '5');?
Answer: A) true
Question 58: Which of the following is used to stop the execution of a function?
Answer: A) return
Question 59: What will console.log([] == ![]); output?
Answer: A) true
Question 60: Which of the following is a correct way to use an if statement?
Answer: B) if (x > 10) { }
Question 61: What is the output of console.log(typeof [] === 'object');?
Answer: A) true
Question 62: Which method would you use to find the last index of an element in an array?
Answer: A) lastIndexOf()
Question 63: Which of the following will not create a variable in JavaScript?
Answer: B) const y;
Question 64: What is the output of console.log(2 + 3 * 4);?
Answer: B) 14
Question 65: How do you define a method in an object?
Answer: D) All of the above
Question 66: What will console.log(1 + '1' + 1); output?
Answer: C) 21
Question 67: Which of the following is used to trigger an asynchronous operation in JavaScript?
Answer: D) All of the above
Question 68: What will be the output of console.log(1 + true);?
Answer: A) 2
Question 69: Which method can be used to join two or more arrays?
Answer: C) concat()
Question 70: What is the output of console.log('5' - 2);?
Answer: A) 3
Question 71: What will console.log(typeof (function(){})); output?
Answer: A) function
Question 72: Which of the following is a correct way to define an arrow function?
Answer: A) const add = (a, b) => a + b;
Question 73: What will console.log(0 == false); output?
Answer: A) true
Question 74: What does the reduce() method do in JavaScript?
Answer: A) Reduces an array to a single value
Question 75: Which of the following will create a new object with the same prototype as the original object?
Answer: D) Both A and C
Question 76: What will be the output of console.log(typeof {});?
Answer: A) object
Question 77: Which of the following statements is correct?
Answer: C) NaN is a number
Question 78: What will console.log(1 + '1' - 1); output?
Answer: B) 10
Question 79: Which of the following is a method of the Array prototype?
Answer: D) All of the above
Question 80: How do you create a new Promise?
Answer: B) new Promise(function(resolve, reject) { });
Question 81: What will console.log(null == undefined); output?
Answer: A) true
Question 82: Which method is used to convert a JSON string into a JavaScript object?
Answer: A) JSON.parse()
Question 83: Which of the following is true about the `let` keyword in JavaScript?
Answer: A) It declares a variable that can be reassigned.
Question 84: What will console.log(2 + '2'); output?
Answer: B) 22
Question 85: Which of the following is a falsy value in JavaScript?
Answer: D) All of the above
Question 86: What is the output of console.log(typeof NaN);?
Answer: A) number
Question 87: Which of the following methods can be used to remove the last element from an array?
Answer: A) pop()
Question 88: How do you declare a constant variable in JavaScript?
Answer: A) const myVar;
Question 89: Which of the following will create an object?
Answer: C) Both A and B
Question 90: What does the `this` keyword refer to in JavaScript?
Answer: D) All of the above
Question 91: How do you add a new element to the end of an array?
Answer: A) array.push(element);
Question 92: Which of the following is not a JavaScript data type?
Answer: D) float
Question 93: What will the following code output? console.log(typeof "Hello");
Answer: A) string
Question 94: How do you find the length of an array?
Answer: B) array.length;
Question 95: What is the correct way to write a JavaScript array?
Answer: B) var colors = ["red", "green", "blue"];
Question 96: Which of the following is a way to define a function in JavaScript?
Answer: C) Both A and B
Question 97: What is a closure in JavaScript?
Answer: A) A function that remembers its outer variables
Question 98: What does `===` do in JavaScript?
Answer: A) Compares value and type
Question 99: Which of the following is used to define a JavaScript object?
Answer: A) { }
Question 100: How can you convert a string to a number in JavaScript?
Answer: C) Both A and B

Showing 51-100 of 500 questions

Contact Tech Spakes Training