Top 500 Javascript MCQ Interview Questions

Question 151: Which of the following can throw an error in JavaScript?
Answer: D) All of the above
Question 152: What is the output of console.log(5 % 2);?
Answer: B) 1
Question 153: Which of the following is not a method of the Array prototype?
Answer: D) each()
Question 154: What will console.log('Hello'.split('l')); output?
Answer: A) ['Hel', 'lo']
Question 155: What does the reduce() method do?
Answer: A) Reduces an array to a single value
Question 156: Which of the following will create a new array from an existing one?
Answer: D) All of the above
Question 157: What will console.log((2 + 3) * 4); output?
Answer: A) 20
Question 158: Which of the following is a valid way to create a set in JavaScript?
Answer: C) Both A and B
Question 159: What is the output of console.log('2' == 2);?
Answer: A) true
Question 160: Which of the following is used to declare a constant in JavaScript?
Answer: C) const
Question 161: What will console.log(2 && 3); output?
Answer: B) 3
Question 162: What is the output of console.log(1 + '2' + 3);?
Answer: A) 123
Question 163: Which of the following methods can be used to get the keys of an object?
Answer: A) Object.keys()
Question 164: What does the find() method do?
Answer: A) Returns the first element that satisfies the provided testing function
Question 165: What will console.log([] + []); output?
Answer: C) ""
Question 166: Which of the following is a falsy value?
Answer: C) 0
Question 167: What is the output of console.log(1 + true);?
Answer: A) 2
Question 168: What does the some() method do?
Answer: A) Checks if at least one element in the array satisfies the condition
Question 169: Which of the following will correctly clone an object?
Answer: D) All of the above
Question 170: What is the output of console.log(3 * null);?
Answer: A) 0
Question 171: What will console.log(false == 0); output?
Answer: A) true
Question 172: Which of the following is a higher-order function?
Answer: D) All of the above
Question 173: What is the output of console.log(NaN === NaN);?
Answer: B) false
Question 174: What will console.log((2 + 3) == 5); output?
Answer: A) true
Question 175: Which of the following can be used to handle exceptions in JavaScript?
Answer: D) All of the above
Question 176: What will console.log(0 == '0'); output?
Answer: A) true
Question 177: Which of the following is used to define an asynchronous function in JavaScript?
Answer: A) async
Question 178: What will console.log(1 + '1' + 1); output?
Answer: B) 111
Question 179: Which of the following methods is used to parse a JSON string into a JavaScript object?
Answer: B) JSON.parse()
Question 180: What will console.log(typeof NaN); output?
Answer: A) "number"
Question 181: What will console.log(!!"hello"); output?
Answer: A) true
Question 182: Which of the following is a way to declare a variable in JavaScript?
Answer: D) All of the above
Question 183: What does the Array.isArray() method do?
Answer: A) Checks if a value is an array
Question 184: What is the output of console.log(typeof null);?
Answer: A) "object"
Question 185: How do you create a new array from an existing array by applying a function to each element?
Answer: A) array.map()
Question 186: Which of the following is NOT a falsy value in JavaScript?
Answer: D) "hello"
Question 187: What is the purpose of the break statement in JavaScript?
Answer: A) Exit a loop
Question 188: What is the output of console.log(1 + 2 + "3");?
Answer: C) "33"
Question 189: How can you create a new object in JavaScript?
Answer: D) All of the above
Question 190: What is a closure in JavaScript?
Answer: A) A function that retains access to its lexical scope
Question 191: What does the this keyword refer to in JavaScript?
Answer: C) The object that is executing the current function
Question 192: Which method is used to remove the last element from an array?
Answer: A) pop()
Question 193: What will console.log(0.1 + 0.2 === 0.3); output?
Answer: B) false
Question 194: How do you define a function in JavaScript?
Answer: A) function myFunction() {}
Question 195: What is the output of console.log("5" + 5);?
Answer: B) "55"
Question 196: What does the Array.push() method do?
Answer: A) Adds one or more elements to the end of an array
Question 197: Which of the following is an example of a JavaScript primitive type?
Answer: C) String
Question 198: How do you check if a variable is an array?
Answer: C) Array.isArray(variable)
Question 199: What is the use of the JSON.stringify() method?
Answer: A) Convert a JavaScript object into a JSON string
Question 200: How do you create a promise in JavaScript?
Answer: A) new Promise(function(resolve, reject) {})

Showing 151-200 of 500 questions

Contact Tech Spakes Training