Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Fundamentals Quiz

Total questions: 29

Worksheet time: 15mins

Name
Class
Date
1.

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

a)

To declare a function

b)

To declare a variable with global scope

c)

To declare a constant variable

d)

To declare a variable with block scope

2.

Which of the following is a reserved word in JavaScript?

a)

function

b)

variable

c)

constant

d)

define

3.

What does the camelCase convention refer to?

a)

Using all uppercase letters

b)

Capitalizing the first letter of each word except the first

c)

Using underscores between words

d)

Writing variables with spaces

4.

Which operator is used for exponentiation in JavaScript?

a)

^^

b)

exp

c)

^

d)

**

5.

What is the result of 'typeof null' in JavaScript?

a)

'object'

b)

'boolean'

c)

'null'

d)

'undefined'

6.

Which method converts a string to an integer in JavaScript?

a)

String

b)

parseFloat

c)

Number

d)

parseInt

7.

What is the difference between '==' and '===' in JavaScript?

a)

'==' checks value only, '===' checks type only

b)

'==' checks value and type, '===' checks value only

c)

'==' checks type only, '===' checks value only

d)

'==' checks value only, '===' checks value and type

8.

Which logical operator represents 'AND' in JavaScript?

a)

&&

b)

&

c)

||

d)

!

9.

What does a guard-clause pattern help with in JavaScript?

a)

Handling exceptions

b)

Looping through arrays

c)

Declaring variables

d)

Simplifying conditional logic

10.

Which control flow statement is used to execute code based on multiple conditions?

a)

if / else if / else

b)

while loop

c)

switch

d)

for loop

11.

What is the purpose of the 'break' statement in loops?

a)

To exit the loop immediately

b)

To skip the current iteration

c)

To pause the loop

d)

To restart the loop

12.

Which method is used to find the position of a substring within a string?

a)

substring

b)

slice

c)

indexOf

d)

charAt

13.

How do you add an element to the end of an array?

a)

pop

b)

unshift

c)

push

d)

shift

14.

Which array method creates a new array with all elements that pass a test?

a)

reduce

b)

forEach

c)

filter

d)

map

15.

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

a)

To declare a new variable

b)

To refer to the current instance of the class

c)

To create a new class

d)

To call a static method

16.

Which method is used to convert an object to an array of its keys?

a)

Object.keys

b)

Object.values

c)

Object.entries

d)

Object.toArray

17.

What is the main advantage of using a 'Set' in JavaScript?

a)

It allows duplicate values

b)

It is immutable

c)

It stores unique values

d)

It is faster than arrays

18.

Which method is used to add a new key-value pair to a Map?

a)

push

b)

insert

c)

add

d)

set

19.

What is the purpose of the 'constructor' method in a class?

a)

To define static methods

b)

To create private variables

c)

To initialize new objects

d)

To inherit from another class

20.

Which of the following is a micro-task in JavaScript?

a)

Promise

b)

setTimeout

c)

Event listener

d)

setInterval

21.

What does the 'typeof' operator return for an array?

a)

'object'

b)

'function'

c)

'array'

d)

'undefined'

22.

Which method is used to remove the last element from an array?

a)

unshift

b)

shift

c)

push

d)

pop

23.

What is the result of 'Boolean(0)' in JavaScript?

a)

true

b)

null

c)

false

d)

undefined

24.

Which method is used to join all elements of an array into a string?

a)

join

b)

concat

c)

slice

d)

splice

25.

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

a)

To iterate over each element without returning a new array

b)

To map each element to a new value

c)

To filter elements based on a condition

d)

To execute a reducer function on each element, resulting in a single output value

26.

Which keyword is used to declare a constant in JavaScript?

a)

const

b)

var

c)

constant

d)

let

27.

What does the 'splice' method do in an array?

a)

Adds/removes elements from an array

b)

Reverses the order of elements in an array

c)

Joins two arrays

d)

Returns a shallow copy of a portion of an array

28.

Which method is used to check if an object has a specific property?

a)

in

b)

hasOwnProperty

c)

Object.entries

d)

Object.keys

29.

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

a)

To reduce the array to a single value

b)

To filter elements based on a condition

c)

To create a new array with the results of calling a function on every element

d)

To execute a provided function once for each array element