wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Javascript

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

Which type of JavaScript language is

a)

Object-oriented

b)

Assembly-language

c)

High-level

d)

Object-based

2.

Which of the following is the correct output for the following JavaScript code:

<script>

x = 10;

y = 5;

z = x / y;

document.getElementById("demo").innerHTML = "The value of z is: " + z;

</script>

a)

2

b)

0

c)

5

d)

Error

3.

In JavaScript, what is a block of statement?

a)
  1. Conditional block

b)
  1. block that contains a single statement

c)
  1. block that combines a number of statements into a single compound statement

d)
  1. both conditional block and a single statement

4.

What will happen, if the following JavaScript code is executed?

<script>
alert(5 + 6);
</script>

a)
  1. An error is displayed

b)
  1. The values of count variable are logged or stored in a particular location or storage

c)

Pop up box appear with the value

d)
  1. An exception is thrown

5.

The following is true about Javascript Objects, excepts

a)

Containers for data values

b)

Can be written with or without decimals

c)

can be assigned with multiple values

6.

Which of the following is the syntax for declaring Javascript array?

a)

var pet = [ "cat", "dog", "bird"]

b)

var pet = [ cat, dog, bird]

c)

var pet = { cat, dog, bird}

d)

var pet = ( cat, dog, bird)

7.

Which of the following is the getElementsByTagName() method ?

a)

return the element by given id value

b)

return the element by given class name

c)

return the element by given tag name

d)

return the element by given name value

8.

What is JavaScript?

a)

JavaScript is a scripting language used to make the website interactive

b)

JavaScript is an assembly language used to make the website interactive

c)

JavaScript is a compiled language used to make the website interactive

d)

None of the mentioned

9.

What is the output of the following JavaScript code snippet?

<p id="demo"> </p>

var txt1 = " Happy";

var txt2 = " Birthday";

document.getElementById("demo").innerHTML = txt2 + txt1;

a)

Happy

b)

Birthday

c)

Happy Birthday

d)

Birthday Happy

10.

Arrays in JavaScript are defined by which of the following statements?

a)

It is an ordered list of objects

b)

It is an ordered list of values

c)

It is an ordered list of string

d)

It is an ordered list of functions