Top 500 Javascript MCQ Interview Questions

Question 251: What will console.log([1, 2, 3].map(x => x * 2)); output?
Answer: B) [2, 4, 6]
Question 252: Which of the following is used to create a new array from an existing array?
Answer: D) All of the above
Question 253: What is the output of console.log(true && false);?
Answer: B) false
Question 254: Which of the following will throw a reference error?
Answer: A) console.log(a);
Question 255: What is the output of console.log([] + []);?
Answer: A) ""
Question 256: What is the output of console.log(1 + 2 + '3' + 4);?
Answer: A) 1234
Question 257: Which method can be used to transform each element in an array?
Answer: A) map()
Question 258: What will console.log('hello'.toUpperCase()); output?
Answer: B) HELLO
Question 259: What is the output of console.log('x' + 'y' + 1);?
Answer: A) xy1
Question 260: Which of the following will cause a TypeError?
Answer: D) console.log(1 + 2 + undefined);
Question 261: What is the output of console.log([1, 2, 3].reverse());?
Answer: B) [3, 2, 1]
Question 262: Which method can be used to sort an array?
Answer: A) sort()
Question 263: What is the output of console.log(false == '0');?
Answer: A) true
Question 264: What is the result of [1, 2, 3].concat([4, 5]);?
Answer: A) [1, 2, 3, 4, 5]
Question 265: What is the output of console.log(typeof NaN);?
Answer: A) number
Question 266: Which of the following is an invalid variable name?
Answer: C) 1myVar
Question 267: What is the output of console.log(typeof null);?
Answer: A) object
Question 268: What will console.log([2, 4, 6].slice(1)); output?
Answer: A) [4, 6]
Question 269: What is the output of console.log('1' == 1);?
Answer: A) true
Question 270: What is the output of console.log([1, 2, 3].join('-'));?
Answer: A) 1-2-3
Question 271: Which of the following is NOT a primitive data type in JavaScript?
Answer: C) Object
Question 272: What is the output of console.log('5' + 5);?
Answer: B) 55
Question 273: Which method is used to add an element at the end of an array?
Answer: A) push()
Question 274: What will console.log([1, 2, 3].indexOf(2)); output?
Answer: B) 1
Question 275: What does JSON stand for?
Answer: A) JavaScript Object Notation
Question 276: What will console.log(typeof [1, 2, 3]); output?
Answer: A) object
Question 277: What is the output of console.log(0.1 + 0.2 === 0.3);?
Answer: B) false
Question 278: Which operator is used to assign a value to a variable?
Answer: A) =
Question 279: What is the output of console.log('a' + + 'b');?
Answer: B) NaN
Question 280: What is the output of console.log(2 + 3 + '7');?
Answer: A) 57
Question 281: What will console.log(typeof null); output?
Answer: A) object
Question 282: Which of the following is a way to define a variable in JavaScript?
Answer: D) All of the above
Question 283: What is the output of console.log('1' == 1);?
Answer: A) true
Question 284: Which of the following is not a looping structure in JavaScript?
Answer: C) foreach
Question 285: What is the output of console.log(typeof [1, 2, 3].length);?
Answer: A) number
Question 286: What is the output of console.log([] + 'abc');?
Answer: A) abc
Question 287: Which method is used to convert a JSON string into a JavaScript object?
Answer: B) JSON.parse()
Question 288: What is the output of console.log([1, 2, 3].join('-'));?
Answer: A) "1-2-3"
Question 289: What is the output of console.log(1 === '1');?
Answer: B) false
Question 290: Which of the following is a method of the Math object?
Answer: D) All of the above
Question 291: What is the output of console.log('a' > 'A');?
Answer: A) true
Question 292: Which of the following is a correct way to create a new array in JavaScript?
Answer: C) Both A and B
Question 293: What will console.log(3 + 4 + '5'); output?
Answer: B) 75
Question 294: Which of the following is a valid way to declare a constant?
Answer: A) const x = 10;
Question 295: What is the output of console.log(Math.max(1, 2, 3));?
Answer: C) 3
Question 296: What will console.log('5' + 5); output?
Answer: B) 55
Question 297: Which of the following is true about JavaScript functions?
Answer: D) All of the above
Question 298: What is the output of console.log(0 == false);?
Answer: A) true
Question 299: What will console.log(typeof NaN); output?
Answer: A) number
Question 300: Which of the following is a correct way to define a string?
Answer: D) All of the above

Showing 251-300 of 500 questions

Contact Tech Spakes Training