Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Quiz

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.
  1. Which keyword is used to declare a variable in JavaScript?

a)

let

b)

const

c)

var

d)

All of the above

2.
  1. Which of the following is NOT a valid JavaScript data type?

a)

String

b)

Boolean

c)

Number

d)

Object

3.
  1. What is the result of the following code: "5" + 5?

a)

10

b)

"55"

c)

"10"

d)

NaN

4.

What does the acronym "JSON" stand for in JavaScript?

a)

JavaScript Object Notation

b)

Java Script Output Note

c)

JavaScript Object Namespace

d)

Java Script On-The-Go

5.

What does the "NaN" value represent in JavaScript?

a)

"New and Nice" value

b)

"Not a Number" value

c)

"No Available Number" value

d)

"Never Again" value

6.

Which of the following is a valid way to declare a variable in JavaScript?

a)

let myVar;

b)

const myVar;

c)

myVar;

d)

var myVar;

7.

Which of the following loop statements will always execute at least once?

a)

for loop

b)

while loop

c)

do-while loop

d)

All of the above

8.
  1. Which keyword is used to define a function in JavaScript?

a)

Def

b)

Function

c)

Create

d)

Define

9.

Which of the following is NOT a comparison operator in JavaScript?

a)

<

b)

>

c)

=

d)

==

10.

Which of the following is NOT a valid way to create an array in JavaScript?

a)

let myArray = [1, 2, 3];

b)

let myArray = new Array(1, 2, 3);

c)

let myArray = 1, 2, 3;

d)

None of the above

11.

Which of the following is NOT a logical operator in JavaScript?

a)

&&

b)

||

c)

!

d)

#

12.

Which of the following is NOT a valid way to declare a JavaScript function?

a)

myFunction = () => {};

b)

function myFunction() {}

c)

let myFunction = function() {};

d)

All of the above are valid

13.

Which of the following is the correct way to add a new element to the end of an array in JavaScript?

a)

array.add("newElement");

b)

array.push("newElement");

c)

array.concat("newElement");

d)

array.append("newElement");

14.

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

a)

"==" compares values and types, while "===" only compares values.

b)

"==" and "===" are interchangeable.

c)

There is no difference between "==" and "===".

d)

"===" compares values and types, while "==" only compares values.

15.

Which of the following is NOT a valid way to execute a function in JavaScript?

a)

myFunction();

b)

myFunction.call();

c)

myFunction.apply(); (Answer)

d)

All of the above are valid

16.

Which of the following is the correct way to remove the last element from an array in JavaScript?

a)

array.slice(-1);

b)

array.splice(-1);

c)

array.removeLast();

d)

array.pop();

17.

Which of the following is NOT a valid way to write a conditional statement in JavaScript?

a)

if (x > 5) {}

b)

switch (x) {}

c)

for (x in array) {}

d)

All of the above are valid

18.

What is the result of the following code: Math.floor(4.6);

(a)  

19.

The (a)   method in JavaScript adds a new element to the beginning of an array.

20.

Which of the following is NOT a valid way to declare a constant in JavaScript?

a)

const myConstant = "value";

b)

let myConstant = "value";

c)

var myConstant = "value";

d)

All of the above are constant