wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Basics Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the index of the first element in a JavaScript array?

a)

1

b)

0

c)

-1

d)

Depends on the array

2.

Which is the correct way to create an array?

a)

let arr = (1, 2, 3)

b)

let arr = {1, 2, 3}

c)

let arr = [1, 2, 3]

d)

let arr =

3.

What does arr.length return?

a)

Last index

b)

Number of elements

c)

Size in memory

d)

Always starts from 0

4.

What does push() do?

a)

Removes first element

b)

Removes last element

c)

Adds element to the end

d)

Adds element to the beginning

5.

What does includes() return?

a)

Index

b)

Number

c)

Boolean

d)

Array

6.

Which method removes the last element from an array?

a)

pop()

b)

shift()

c)

slice()

d)

splice()

7.

What is an object mainly used for?

a)

Ordered data

b)

Indexed data

c)

Key–value data

d)

Mathematical operations

8.

How do you correctly access the name property of an object user?

a)

user[name]

b)

user.name

c)

user->name

d)

user::name

9.

Which one is NOT valid for objects?

a)

Dot notation

b)

Bracket notation

c)

Index access

d)

Key access

10.

Which loop is best for looping through an array’s values?

a)

for

b)

for...in

c)

for...of

d)

while

11.

Which loop is used to loop through object keys?

a)

for

b)

for...of

c)

for...in

d)

do...while

12.

What does for...in give you when looping an object?

a)

Values

b)

Indexes

c)

Keys

d)

Arrays

13.

Which is the correct way to get all keys of an object?

a)

obj.keys()

b)

keys(obj)

c)

Object.keys(obj)

d)

getKeys(obj)

14.

What does Object.values(obj) return?

a)

Object

b)

Boolean

c)

Array of values

d)

Array of keys

15.

What does a function return if there is no return statement?

a)

0

b)

false

c)

undefined

d)

null