wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Quiz

Total questions: 20

Worksheet time: 7mins

Name
Class
Date
1.

Which type of JavaScript language is ___

a)
  1. Object-Oriented

b)
  1. Object-Based

c)
  1. Assembly-language

d)
  1. High-level

2.

What is the purpose of the 'this' keyword in JavaScript?

a)

  1. To refer to the current object

b)

  1. To declare a variable

c)

  1. To create a loop

d)

  1. To import external libraries

3.

What does the 'typeof' operator in JavaScript return?

a)

  1. The data type of a variable

b)

  1. The value of a variable

c)

  1. The length of a string

d)

  1. The index of an array element

4.

What is the correct way to comment a single line in JavaScript?

a)

  1. // This is a comment

b)

  1. /* This is a comment */

c)

  1. # This is a comment

d)

  1. %% This is a comment

5.

What is the purpose of the 'let' keyword in JavaScript?

a)

  1. To declare a block-scoped variable

b)

  1. To refer to the current object

c)

  1. To create a loop

d)

  1. To import external libraries

6.

What does the 'NaN' value represent in JavaScript?

a)

  1. Not a Number

b)

  1. Null

c)

  1. Undefined

d)

  1. Infinity

7.

Which method is used to add a new element to the end of an array in JavaScript?

a)

  1. push()

b)

  1. pop()

c)

  1. shift()

d)

  1. unshift()

8.

What is the purpose of the 'forEach' method in JavaScript?

a)

  1. To iterate over the elements of an array

b)

  1. To add a new element to the end of an array

c)

  1. To remove the first element of an array

d)

  1. To check if an element exists in an array

9.

What is the correct way to declare a constant variable in JavaScript?

a)

  1. const myVar = 10;

b)

  1. let myVar = 10;

c)

  1. var myVar = 10;

d)

  1. constant myVar = 10;

10.

What does the '=== ' operator in JavaScript compare?

a)

  1. Value and type

b)

  1. Value only

c)

  1. Type only

d)

  1. Reference in memory

11.

What is the purpose of the 'map' method in JavaScript?

a)

  1. To transform each element of an array

b)

  1. To add a new element to the end of an array

c)

  1. To remove the first element of an array

d)

  1. To check if an element exists in an array

12.

What does the 'filter' method do in JavaScript?

a)

  1. Creates a new array with elements that pass a test

b)

  1. Sorts the elements of an array

c)

  1. Reverses the order of elements in an array

d)

  1. Concatenates two arrays

13.

How can you access the last element of an array in JavaScript?

a)

  1. By using the index of the last element

b)

  1. By using the 'last' keyword

c)

  1. By using the 'end' keyword

d)

  1. By using the 'length' property of the array

14.
  1. varx=5,y=1  

  2. var obj ={ x:10}  

  3. with(obj)  

  4. {  

  5.       alert(y)  

  6. }  

a)

1

b)

error

c)

10

d)

5

15.

What is the purpose of the 'reduce' method in JavaScript?

a)

  1. To reduce the array to a single value

b)

  1. To add a new element to the end of an array

c)

  1. To remove the first element of an array

d)

  1. To check if an element exists in an array

16.

What is the purpose of the 'find' method in JavaScript?

a)

  1. To find the first element in an array that satisfies a condition

b)

  1. To add a new element to the end of an array

c)

  1. To remove the first element of an array

d)

  1. To check if an element exists in an array

17.

What is the purpose of the 'some' method in JavaScript?

a)

  1. To check if at least one element in an array satisfies a condition

b)

  1. To add a new element to the end of an array

c)

  1. To remove the first element of an array

d)

  1. To check if an element exists in an array

18.

What is the purpose of the 'slice' method in JavaScript?

a)

  1. To extract a section of an array

b)

  1. To add a new element to the end of an array

c)

  1. To remove the first element of an array

d)

  1. To check if an element exists in an array

19.

What does the 'concat' method do in JavaScript?

a)

  1. Combines two or more arrays

b)

  1. Sorts the elements of an array

c)

  1. Reverses the order of elements in an array

d)

  1. Filters elements based on a condition

20.

What is the purpose of the 'findIndex' method in JavaScript?

a)

  1. To find the index of the first element in an array that satisfies a condition

b)

  1. To add a new element to the end of an array

c)

  1. To remove the first element of an array

d)

  1. To check if an element exists in an array