Looking for a comprehensive resource to test your knowledge of JavaScript? Look no further than our collection of 50+ multiple-choice questions with answers! Covering a wide range of topics including arrays, strings, loops, and more, this resource is perfect for anyone looking to brush up on their JavaScript skills. Whether you’re a beginner or an experienced developer, these questions will challenge your understanding and help you deepen your knowledge of this popular programming language.

What is JavaScript?

  • A. A server-side language
  • B. A client-side language
  • C. Both A and B
  • D. None of the above

Answer: B

Which of the following is not a data type in JavaScript?


  • A. Boolean
  • B. Integer
  • C. String
  • D. Object

Answer: B

What is the correct syntax for a JavaScript comment?

  • A. //
  • B. ##
  • C. /
  • D. %

Answer: A

What is the output of console.log(10 + “20”) in JavaScript?

  • A. 1020
  • B. 30
  • C. 102
  • D. Error

Answer: A

Which of the following is a built-in JavaScript function for converting a string to a number?

  • A. parseInt()
  • B. toString()
  • C. parseFloat()
  • D. stringify()

Answer: A

What is the correct way to declare a JavaScript variable?

  • A. var x = 5;
  • B. variable x = 5;
  • C. x = 5;
  • D. declare x = 5;

Answer: A

Which of the following is a JavaScript loop statement?

  • A. for
  • B. switch
  • C. if
  • D. else

Answer: A

What is the output of console.log(typeof null) in JavaScript?

  • A. null
  • B. undefined
  • C. object
  • D. number

Answer: C

Which of the following is a JavaScript comparison operator?

  • A. ++
  • B. **
  • C. ==
  • D. //

Answer: C

Which of the following is not a JavaScript logical operator?

  • A. &&
  • B. ||
  • C. !
  • D. #

Answer: D

What is the output of console.log(Math.floor(Math.random() * 10)) in JavaScript?

  • A. A random number between 0 and 10
  • B. A random number between 1 and 10
  • C. A random number between 0 and 9
  • D. A random number between 1 and 9

Answer: C

Which of the following is a JavaScript array method for adding an element to the end of an array?

  • A. pop()
  • B. push()
  • C. shift()
  • D. unshift()

Answer: B

What is the output of console.log(“10” + 20 – 5) in JavaScript?

  • A. 15
  • B. 1020
  • C. 25
  • D. Error

Answer: B

What is the output of console.log(typeof NaN) in JavaScript?

  • A. number
  • B. NaN
  • C. undefined
  • D. object

Answer: A

Which of the following is a JavaScript function declaration?

  • A. function myFunction() {}
  • B. myFunction() {}
  • C. var myFunction = function() {}
  • D. All of the above

Answer: A

What is the output of console.log(2 + “2”) in JavaScript?

  • A. “4”
  • B. 4
  • C. “22”
  • D. Error

Answer: C

Which of the following is a JavaScript string method for converting a string to uppercase?

  • A. toUpper()
  • B. upperCase()
  • C. toUpperCase()
  • D. caseUpper()

Answer: C

What is the output of console.log(true || false) in JavaScript?

  • A. true
  • B. false
  • C. null
  • D. Error

Answer: A

What is the output of console.log(typeof []) in JavaScript?

  • A. object
  • B. array
  • C. undefined
  • D. Error

Answer: A

Which of the following is a JavaScript function for converting a number to a string?

  • A. toString()
  • B. parseInt()
  • C. stringify()
  • D. None of the above

Answer: A

What is the output of console.log(Math.ceil(4.3)) in JavaScript?

  • A. 4
  • B. 5
  • C. 4.3
  • D. Error

Answer: B

Which of the following is a JavaScript array method for removing the last element from an array?

  • A. pop()
  • B. push()
  • C. shift()
  • D. unshift()

Answer: A

What is the output of console.log(10 > 5 && 5 < 4) in JavaScript?

  • A. true
  • B. false
  • C. null
  • D. Error

Answer: B

Which of the following is a JavaScript string method for finding the index of a specified character in a string?

  • A. indexOf()
  • B. charAt()
  • C. slice()
  • D. None of the above

Answer: A

What is the output of console.log(“hello”.length) in JavaScript?

  • A. hello
  • B. 5
  • C. undefined
  • D. Error

Answer: B

Which of the following is a JavaScript conditional statement?

  • A. for
  • B. switch
  • C. if
  • D. else

Answer: C

What is the output of console.log(typeof “hello”) in JavaScript?

  • A. string
  • B. object
  • C. undefined
  • D. Error

Answer: A

Which of the following is a JavaScript array method for reversing the order of the elements in an array?

  • A. reverse()
  • B. sort()
  • C. concat()
  • D. None of the above

Answer: A

What is the output of console.log(Math.pow(2, 3)) in JavaScript?

  • A. 2
  • B. 3
  • C. 6
  • D. 8

Answer: D

Which of the following is a JavaScript function for rounding a number to the nearest integer?

  • A. ceil()
  • B. floor()
  • C. round()
  • D. None of the above

Answer: C

What is the output of console.log(typeof true) in JavaScript?

  • A. boolean
  • B. object
  • C. undefined
  • D. Error

Answer: A

Which of the following is a JavaScript array method for adding an element to the beginning of an array?

  • A. pop()
  • B. push()
  • C. shift()
  • D. unshift()

Answer: D

What is the output of console.log(“hello” + “world”) in JavaScript?

  • A. “helloworld”
  • B. “hello world”
  • C. “hello+world”
  • D. Error

Answer: A

Which of the following is a JavaScript function for generating a random number between 0 and 1?

  • A. Math.random()
  • B. Math.floor()
  • C. Math.ceil()
  • D. None of the above

Answer: A

What is the output of console.log(typeof undefined) in JavaScript?

  • A. undefined
  • B. object
  • C. null
  • D. Error

Answer: A

Which of the following is a JavaScript string method for removing whitespace from the beginning and end of a string?

  • A. trim()
  • B. slice()
  • C. replace()
  • D. None of the above

Answer: A

Which of the following is a JavaScript array method for sorting the elements in an array?

  • A. reverse()
  • B. sort()
  • C. splice()
  • D. None of the above

Answer: B

What is the output of console.log(“hello”.toUpperCase()) in JavaScript?

  • A. hello
  • B. Hello
  • C. HELLO
  • D. Error

Answer: C

Which of the following is a JavaScript function for converting a string to a number?

  • A. toString()
  • B. parseInt()
  • C. parseFloat()
  • D. None of the above

Answer: B

What is the output of console.log(typeof NaN) in JavaScript?

  • A. number
  • B. string
  • C. undefined
  • D. Error

Answer: A

Which of the following is a JavaScript array method for adding one or more elements to the end of an array?

  • A. pop()
  • B. push()
  • C. shift()
  • D. unshift()

Answer: B

What is the output of console.log(10 === “10”) in JavaScript?

  • A. true
  • B. false
  • C. null
  • D. Error

Answer: B

Which of the following is a JavaScript function for finding the maximum value in an array?

  • A. Math.min()
  • B. Math.max()
  • C. Array.min()
  • D. Array.max()

Answer: B

What is the output of console.log(“hello”.charAt(0)) in JavaScript?

  • A. h
  • B. e
  • C. l
  • D. o

Answer: A

Which of the following is a JavaScript string method for replacing a specified character in a string with another character?

  • A. replace()
  • B. slice()
  • C. concat()
  • D. None of the above

Answer: A

What is the output of console.log(10 % 3) in JavaScript?

  • A. 1
  • B. 2
  • C. 3
  • D. Error

Answer: A

Which of the following is a JavaScript array method for removing elements from an array and replacing them with new elements?

  • A. pop()
  • B. push()
  • C. splice()
  • D. unshift()

Answer: C

What is the output of console.log(Math.floor(4.9)) in JavaScript?

  • A. 4
  • B. 5
  • C. 4.9
  • D. Error

Answer: A

Which of the following is a JavaScript loop statement for repeating a block of code as long as a specified condition is true?

  • A. for loop
  • B. while loop
  • C. do…while loop
  • D. switch statement

Answer: B

What is the output of console.log(“hello”.length) in JavaScript?

  • A. hello
  • B. 5
  • C. null
  • D. Error

Answer: B

Which of the following is a JavaScript function for generating a random number between 0 and 1?

  • A. random()
  • B. floor()
  • C. ceil()
  • D. None of the above

Answer: A

What is the output of console.log(10 + “10”) in JavaScript?

  • A. 1010
  • B. 20
  • C. 101
  • D. Error

Answer: A

Which of the following is a JavaScript array method for removing the last element from an array?

  • A. pop()
  • B. push()
  • C. shift()
  • D. unshift()

Answer: A

What is the output of console.log(Math.pow(2, 3)) in JavaScript?

  • A. 2
  • B. 3
  • C. 6
  • D. 8

Answer: D

Which of the following is a JavaScript string method for extracting a section of a string and returning a new string?

  • A. slice()
  • B. replace()
  • C. concat()
  • D. None of the above

Answer: A

Which of the following is a JavaScript array method for removing the first element from an array?

  • A. pop()
  • B. push()
  • C. shift()
  • D. unshift()

Answer: C

What is the output of console.log(5 > 3 && 10 < 20) in JavaScript?

  • A. true
  • B. false
  • C. null
  • D. Error

Answer: A

5/5 (1)