wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Quiz

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

function aaa() {

return

{

test: 1

};

}

alert(typeof aaa());


What does the above alert?

a)

User defined

b)

Object

c)

Number

d)

function

2.

Inside which HTML element do we put the JavaScript?

a)

<script>

b)

<javaScript>

c)

<js>

d)

<scripting>

3.

Where is the correct place to insert a JavaScript?

a)

The <head> section

b)

The <body> section

c)

both the <head> and <body> section are correct

4.

Which is the correct way to write a JavaScript array?

a)

var txt = new Array(1:"arr",2:"kim",3:"jim")

b)

var txt = new Array:1=(" arr ")2=("kim")3=("jim")

c)

var txt = new Array("arr ","kim","jim")

d)

var txt = new Array=" arr ","kim","jim"

5.

Which of the following is correct to write “Hello World” on the web page?

a)

System.out.println(“Hello World”)

b)

print(“Hello World”)

c)

document.write(“Hello World”)

d)

response.write(“Hello World”)

6.

Which of the following is not a valid JavaScript variable name?

a)

2java

b)

_java_and_ java _names

c)

javaandjava

d)

None of the above

7.

Why so Java and JavaScript have similar name?

a)

Java Script is a stripped-down version of Java

b)

The syntax of JavaScript is loosely based on Java syntax

c)

They both support Object Oriented Programming

d)

None of the above

8.

How do you create a function in JavaScript?

a)

function myFunction()

b)

function:myFunction()

c)

function=myFunction()

9.

How do you call a function named "myFunction"?

a)

call function myFunction()

b)

call myFunction()

c)

myFunction()

10.

How can you add a comment in a JavaScript?

a)

//This is comment

b)

'This is comment

c)

<!-- This is comment-->

11.

How do you declare a JavaScript variable?

a)

v carName

b)

variable carName

c)

var carName

12.

Is JavaScript case-sensitive?

a)

yes

b)

No