wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Output

Total questions: 25

Worksheet time: 50mins

Name
Class
Date
1.

__________ is a JavaScript library that implements the most common user interface elements and interactions like sliders, accordions, tabs, and so on.

a)

A. JavaScript

b)

B. JQuery UI

c)

C. VTS

d)

D. JCL

2.

Choose the correct JavaScript syntax to change the content of the following HTML code.

<p id="geek">GeeksforGeeks</p>

a)

A) document.getElement(“geek”).innerHTML=”I am a Geek”;

b)

B) document.getElementById(“geek”).innerHTML=”I am a Geek”;

c)

C) document.getId(“geek”)=”I am a Geek”;

d)

D) document.getElementById(“geek”).innerHTML=I am a Geek;

3.

Which of the following is the correct syntax to display “GeeksforGeeks” in an alert box using JavaScript?

a)

A. alertbox(“GeeksforGeeks”);

b)

B. msg(“GeeksforGeeks”);

c)

C. msgbox(“GeeksforGeeks”);

d)

D. alert(“GeeksforGeeks”);

4.

What is the correct syntax for referring to an external script called “geek.js”?

a)

A. <script src=”geek.js”>

b)

B. <script href=”geek.js”>

c)

C. <script ref=”geek.js”>

d)

D. <script name=”geek.js”>

5.

Predict the output of the following JavaScript code.

<script type="text/javascript">

a = 8 + "8";

document.write(a);

</script>

a)

A) 16

b)

B) Complilation Error

c)

C) 88

d)

D) Run Time Error

6.

Predict the output of the following JavaScript code.

<script type="text/javascript">

var a="GeeksforGeeks";

var x=a.lastIndexOf("G");

document.write(x);

</script>

a)

A) 8

b)

B) 0

c)

C) 9

d)

D) Error

7.

Which of the following is not a reserved word in JavaScript?

a)

A. interface

b)

B. throws

c)

C. program

d)

D. short

8.

Predict the output of the following JavaScript code.

<script type="text/javascript" language="javascript">

var a = "GeeksforGeeks";

var result = a.substring(4, 5);

document.write(result);

</script>

a)

A. sf

b)

B. ks

c)

C. s

d)

D. k

9.

Predict the output of the following JavaScript code.

<script type="text/javascript" language="javascript">

var x=5;

var y=6;

var res=eval("x*y");

document.write(res);

</script>

a)

A. “30”

b)

B. 30

c)

C. 5*6

d)

D. “5*6”

10.

Which of the following is a disadvantage of using JavaScript?

a)

A - Client-side JavaScript does not allow the reading or writing of files.

b)

B - JavaScript can not be used for Networking applications because there is no such support available.

c)

C - JavaScript doesn't have any multithreading or multiprocess capabilities.

d)

D - All of the above.

11.

Can you assign a anonymous function to a variable?

a)

A - true

b)

B - false

12.

Which built-in method returns the string representation of the number's value?

a)

A - toValue()

b)

B - toNumber()

c)

C - toString()

d)

D - None of the above.

13.

Which of the following function of String object splits a String object into an array of strings by separating the string into substrings?

a)

A - slice()

b)

B - split()

c)

C - replace()

d)

D - search()

14.

Which of the following function of Array object returns true if every element in this array satisfies the provided testing function?

a)

A - concat()

b)

B - every()

c)

C - push()

d)

D - some()

15.

Which of the following function of Array object extracts a section of an array and returns a new array?

a)

A - reverse()

b)

B - shift()

c)

C - slice()

d)

D - some()

16.

JavaScript is designed for following purpose -

a)

A.To Style HTML Pages

b)

B.To add interactivity to HTML Pages.

c)

C.To Execute Query Related to DB on Server

d)

D.To Perform Server Side Scripting Operation

17.

JavaScript Code is written inside file having extension __________.

a)

.jsc

b)

.jvs

c)

.javascript

d)

.js

18.

Why JavaScript is called as Lightweight Programming Language ?

a)

because JS is client side scripting

b)

because JS can provide programming functionality inside but does not perform stronger operations like Java and C++.

c)

because JS is available free of cost.

d)

because we can add programming functionality inside JS

19.

State the correct place of JS Code inside HTML.

a)

A.Inside Head

b)

B.Inside Body

c)

C.Inside Single JavaScript File

d)

D.All of these

20.

Is this placement of JS code inside HTML Element is Error Free ?

<html><head><title>My Page</title>

</head>

<body>

<a href="javascript:myFunction();">Click here</a>

<script language="javascript" type="text/javascript">

function myFunction() {

alert('Hello world');

}

</script>

</body>

</html>

a)

YES

b)

NO

21.

JS code included inside head section is loaded before loading page.

a)

TRUE

b)

FALSE

22.

It is good to include JS code inside footer section in order to speed up the Page loading time of Webpage.

a)

TRUE

b)

FALSE

23.

Which of the following Attribute is used to include External JS code inside your HTML Document -

a)

script

b)

src

c)

link

d)

ext

24.

JavaScript is Case Sensitive !!Say True or False

a)

TRUE

b)

FALSE

25.

It is not necessary to write Semicolon at the end of JS statement !!

a)

YES

b)

NO