Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS_QUIZ=2

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What will the following code output: console.log(0 == '0');?

a)

a) true

b)

b) false

c)

c) undefined

d)

d) Error

2.

Which of the following methods can be used to remove the last element from an array?

a)

b) array.shift()

b)

c) array.removeLast()

c)

a) array.pop()

d)

d) array.delete()

3.

What is the result of using the 'typeof' operator on an array?

a)

'array'

b)

'object'

c)

'undefined'

d)

'list'

4.

Which of the following correctly defines an arrow function?

a)

b) () => {}

b)

d) => function() {}

c)

a) function => {}

d)

c) function() => {}

5.

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

a)

a) To refer to the global object

b)

c) To create a new object

c)

d) To define a function

d)

b) To refer to the current object

6.

What will be the result of this code considering logical operators?

a)
  • a) 90

b)
  • b) 110

c)
  • c) false

d)
  • d) undefined

7.

15. What will the following code print considering switch fall-through behavior?

a)
  • a) One

b)
  • b) Two

c)
  • c) Two Three

d)
  • d) One Two Three

8.

How do you create a string with dynamic content using template literals?

a)

a) 'Hello' + variable

b)

b) `Hello ${variable}`

c)

c) ("Hello", variable)

d)

d) concat('Hello', variable)

9.

What will be the result of the following code?

a)
  • a) A

b)
  • b) B

c)
  • c) C

d)
  • d) Error

10.

Which of the following is a valid if statement in JavaScript?

a)
  • a) if (x = 5) { }

b)
  • b) if x > 5 { }

c)
  • c) if (x > 5) { }

d)
  • d) if (x 5) { }

11.

What will the following code output?

a)
  • a) 10

b)
  • b) 5

c)
  • c) 55

d)
  • d) Error

12.

.What will be the output of this code?

a)
  • a) 3 + 4 = 7

b)
  • b) 3 + 4 = 34

c)
  • c) 7

d)
  • d) undefined

13.

What will the following code output regarding block scoping with let and var?

a)
  • a) 10 20

b)
  • b) 20 20

c)
  • c) 20 10

d)
  • d) 10 10

14.

4. What will the following code output when continue is used inside a loop?

a)
  • a) 0 1 2

b)
  • b) 0 1 2 4

c)
  • c) 1 2 3 4

d)
  • d) 0 1 2 3 4

15.
A JavaScript file has an extension name of
a)
.jscp
b)
.js
c)
.css
d)
.Jp
16.

How can a developer show a pop-up message to the user?

a)

alert

b)

prompt

c)

console.log

d)

<p> tag

17.
Which one of the following is the symbol for implementing the AND operator?
a)
&&
b)
**
c)
||
d)
++
18.
JavaScript code is embedded in HTML documents between <script> and </script> tags.
a)
True
b)
False
19.

What does the reduce() method return?

a)

A new array

b)
  1. A boolean

c)
  1. A single value

d)
  1. An object

20.

What is the output?
const nums = [1, 2, 3];

nums.forEach(num => num * 2);

console.log(nums);

a)

[1,2,3]

b)

[2,4,6]

c)

undefined

d)

error