1) In which year JavaScript language developed?
a) May 1995
b) June 1980
c) January 1999
d) May 1994
Answer: a) May 1995
2) Which of the following is not a primitive data type in JavaScript?
a) String
b) Number
c) Array
d) Boolean
Answer: c) Array
3) What does DOM stand for in JavaScript?
a) Document Object Model
b) Data Object Model
c) Document Oriented Model
d) Dynamic Object Manipulation
Answer: a) Document Object Model
4) Which keyword is used to declare a variable in JavaScript?
a) var
b) variable
c) int
d) v
Answer: a) var
5) What is the purpose of the 'isNaN()' function in JavaScript?
a) To check if a value is a number
b) To convert a string to a number
c) To check if a value is not a number
d) To round off a number
Answer: c) To check if a value is not a number
6) Which operator is used to concatenate strings in JavaScript?
a) +
b) &
c) *
d) /
Answer: a) +
7) What does the === operator do in JavaScript?
a) Assigns a value to a variable
b) Checks for equality without type conversion
c) Performs a strict comparison, including type
d) Checks for inequality without type conversion
Answer: c) Performs a strict comparison, including type
8) Which function is used to execute a block of code repeatedly at certain intervals?
a) setInterval()
b) setTimeout()
c) executeInterval()
d) loopInterval()
Answer: a) setInterval()
9) What is the purpose of the querySelector() method in JavaScript?
a) To select and modify HTML elements
b) To query a database
c) To select the first element that matches a specified CSS selector
d) To select all elements with a specified class
Answer: c) To select the first element that matches a specified CSS selector
10) Which built-in method is used to convert a string to lowercase letters?
a) toLowerCase()
b) lowerCase()
c) changeCase("lower")
d) convert("lower")
Answer: a) toLowerCase()
11) What does the typeof operator return when used on an array?
a) "array"
b) "object"
c) "arrayobject"
d) "undefined"
Answer: b) "object"
12) What is the purpose of the push() method in JavaScript arrays?
a) Removes the last element from an array
b) Adds one or more elements to the end of an array
c) Sorts the elements of an array
d) Reverses the order of the elements in an array
Answer: b) Adds one or more elements to the end of an array
13) Which keyword is used to prevent the modification of a variable in JavaScript?
a) immutable
b) final
c) const
d) freeze
Answer: c) const
14) What does the splice() method do in JavaScript arrays?
a) Adds or removes elements from an array
b) Sorts the elements of an array
c) Reverses the order of the elements in an array
d) Concatenates two arrays
Answer: a) Adds or removes elements from an array
15) Which event is triggered when a user clicks on an HTML element?
a) mouseover
b) click
c) hover
d) select
Answer: b) click