Google News
logo
JavaScript - Quiz(MCQ)
1 .
Who is inventor of JavaScript ?
A)
John Resig
B)
Brendan Eich
C)
Rasmus Lerdorf
D)
Guido van Rossum

Correct Answer :  

Brendan Eich

2 .
JavaScript initial release date ?
A)
December 4, 1995
B)
December 9, 1995
C)
December 15, 1995
D)
December 21, 1995

Correct Answer :  

December 4, 1995

3 .
To insert a JavaScript into an HTML page, which tag is used?
A)
<script=’javascript’>
B)
<javascript>
C)
<script>
D)
<js>

Correct Answer :  

<script>

4 .
Where is the correct place to insert a JavaScript?
A)
The <head> section
B)
The <body> section
C)
The <footer> section
D)
All of The above

Correct Answer :  

All of The above

5 .
What is the correct syntax for referring to an external script called "xxx.js"?
A)
<script src="xxx.js"></script>
B)
<script href="xxx.js"></script>
C)
<a src="xxx.js"></a>
D)
<a href="xxx.js"></a>

Correct Answer :  

<script src="xxx.js"></script>

6 .
How can you add a comment in a JavaScript?
A)
<!--This is a comment-->
B)
'This is a comment
C)
//This is a comment
D)
/This is a comment

Correct Answer :  

//This is a comment

7 .
How to insert a comment that has more than one line?
A)
/* This comment has
   more than one line */
B)
//This comment has
   more than one line//
C)
<!-- This comment has
   more than one line -->
D)
// This comment has
   more than one line

Correct Answer :  

/* This comment has
   more than one line */

8 .
How do you write "Hello World" in ana alert box?
A)
alert("Hello World");
B)
msg("Hello World");
C)
msgBox("Hello World");
D)
alertBox("Hello World");

Correct Answer :  

alert("Hello World");

9 .
What language defines the behavior of a web page?
A)
HTML
B)
CSS
C)
XML
D)
JavaScript

Correct Answer :  

JavaScript

10 .
What is the alternate name for Java script?
A)
LimeScript 
B)
Both a and d
C)
ECMScript
D)
ECMAScript

Correct Answer :  

ECMAScript

11 .
__________ JavaScript is also called client-side JavaScript.
A)
Microsoft
B)
Navigator
C)
LiveWire 
D)
Native

Correct Answer :  

Navigator

12 .
Which of the following is not a reserved word?
A)
throw
B)
void
C)
return
D)
program

Correct Answer :  

program

13 .
Which of the following is a server-side Java Script object?
A)
Function 
B)
File
C)
FileUpload 
D)
Date

Correct Answer :  

File

14 .
Which of the following is a client-side Java Script object?
A)
File
B)
Function
C)
FileUpload
D)
Time

Correct Answer :  

FileUpload

15 .
What’s the correct syntax for creating a Date object for January 7, 1991?
A)
new Date(1, 7, 1991);
B)
new Date(0, 7, 1991);
C)
new Date(1991, 0, 7);
D)
new Date(1991, 1, 7);

Correct Answer :  

new Date(1991, 0, 7);

16 .
What is the correct JavaScript syntax to change the content of the HTML element below?
<p id="demo">Free Time Learn Demo.</p>
A)
#demo.innerHTML = "Hello World!";
B)
document.getElementByName("p").innerHTML = "Hello World!";
C)
document.getElement("p").innerHTML = "Hello World!";
D)
document.getElementById("demo").innerHTML = "Hello World!";

Correct Answer :  

document.getElementById("demo").innerHTML = "Hello World!";

17 .
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”)

Correct Answer :  

document.write(“Hello World”)

18 .
Which operator is used to assign a value to a variable?
A)
=
B)
x
C)
*
D)
-

Correct Answer :   =

19 .
How do you create a function in JavaScript?
A)
function:myFunction()
B)
function = myFunction()
C)
function myFunction()
D)
function-myFunction()

Correct Answer :  

function myFunction()

20 .
How do you declare a JavaScript variable?
A)
variable carName;
B)
var carName;
C)
v carName;
D)
All of the above

Correct Answer :  

var carName;

21 .
How to write an IF statement in JavaScript?
A)
if i = 5
B)
if (i == 5)
C)
if i = 5 then
D)
if i == 5 then

Correct Answer :  

if (i == 5)

22 .
How to write an IF statement for executing some code if "i" is NOT equal to 5?
A)
if (i <> 5)
B)
if i <> 5
C)
if i =! 5 then
D)
if (i != 5)

Correct Answer :  

if (i != 5)

23 .
How does a WHILE loop start?
A)
while (i <= 10)
B)
while i = 1 to 10
C)
while (i <= 10; i++)
D)
None of the above.

Correct Answer :  

while (i <= 10)

24 .
How does a FOR loop start?
A)
for i = 1 to 5
B)
for (i <= 5; i++)
C)
for (i = 0; i <= 5)
D)
for (i = 0; i <= 5; i++)

Correct Answer :  

for (i = 0; i <= 5; i++)

25 .
Which of these is a correct method to create a new array?
A)
var myArray = ();
B)
var myArray = [];
C)
var myArray = {};
D)
var myArray = array();

Correct Answer :  

var myArray = [];

26 .
How to append a value to an array of Java Script?
A)
arr[arr.length] = value
B)
arr[arr.length+1] = new Arrays()
C)
arr[arr.length-1] = value
D)
arr[arr.length*1] = value

Correct Answer :  

arr[arr.length] = value

27 .
How to return the first value of this array?
var myArr = [1, 2, 3, 4, 5];
A)
myArr[0];
B)
myArr(1);
C)
myArr[1];
D)
myArr(0);

Correct Answer :  

myArr[0];

28 .
Which is the correct way to write a JavaScript array?
A)
var txt = new Array(1:"abc",2:"efg",3:"xyz")
B)
var txt = new Array:1=(" abc ")2=("efg")3=("xyz")
C)
var txt = new Array("abc","efg","xyz")
D)
var txt = new Array=" abc ","efg","xyz"

Correct Answer :  

var txt = new Array("abc","efg","xyz")

29 .
Which event occurs when the user clicks on an HTML element?
A)
onmouseclick
B)
onmouseover
C)
onclick
D)
onchange

Correct Answer :  

onclick

30 .
Which of the following is the tainted property of a window object in Java Script?
A)
Pathname
B)
Protocol
C)
Defaultstatus
D)
Host

Correct Answer :  

Defaultstatus

31 .
Which attribute needs to be changed to make elements invisible?
A)
visibilty
B)
visible
C)
invisibility
D)
invisible

Correct Answer :  

visibilty

32 .
Which is not a primitive data type in JavaScript?
A)
boolean
B)
number
C)
string
D)
character

Correct Answer :  

character

33 .
Which event fires whenever a control loses focus?
A)
onclick
B)
onmove
C)
onblur
D)
onchange

Correct Answer :  

onblur

34 .
Which of the ways below is incorrect of instantiating a date?
A)
new Date(dateString)
B)
new Date()
C)
new Date(seconds)
D)
new Date(year, month, day, hours, minutes, seconds, milliseconds)

Correct Answer :  

new Date(seconds)

35 .
What is the correct JavaScript syntax for opening a new window called "ftl" ?
A)
ftl = window.open("http://www.freetimelearning.com");
B)
ftl = window.new("http://www.freetimelearning.com");
C)
ftl = window.targer("http://www.freetimelearning.com");
D)
ftl = new.window("http://www.freetimelearning.com");

Correct Answer :  

ftl = window.open("http://www.freetimelearning.com");

36 .
Which of the following is used to capture all click events in a window?
A)
window.captureEvents(Event.CLICK);
B)
window.routeEvents(Event.CLICK );
C)
window.handleEvents (Event.CLICK)
D)
window.raiseEvents(Event.CLICK );

Correct Answer :  

window.captureEvents(Event.CLICK);

37 .
How do you round the number 7.25, to the nearest integer?
A)
rnd(7.25)
B)
Math.rnd(7.25)
C)
Math.round(7.25)
D)
round(7.25)

Correct Answer :  

Math.round(7.25)

38 .
How would one declare a string variable?
A)
Any of these
B)
var fName = “FreeTimeLearn”;
C)
var names = “7”;
D)
var fName = new String;

Correct Answer :   Any of these

39 .
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

Correct Answer :  

The syntax of JavaScript is loosely based on Java syntax

40 .
How do you find the number with the highest value of x and y?
A)
top(x, y)
B)
Math.ceil(x, y)
C)
Math.max(x, y)
D)
ceil(x, y)

Correct Answer :  

Math.max(x, y)

41 .
What is negative infinity in Java script?
A)
Any of below
B)
number in JavaScript, derived by dividing number by a negative number.
C)
number in JavaScript, derived by dividing number by zero. 
D)
number in JavaScript, derived by dividing negative number by zero

Correct Answer :  

number in JavaScript, derived by dividing negative number by zero

42 .
Where do you use the “break” statement?
A)
To add a value to an array.
B)
To terminate an Object statement.
C)
To terminate a switch statement, loop, or labeled block.
D)
To divide (or “break”) a mathematical value in half.

Correct Answer :  

To terminate a switch statement, loop, or labeled block. 

43 .
What is the value of x?
var x = ‘1’+2+3;
A)
6
B)
15
C)
“123” 
D)
5

Correct Answer :  

“123”

44 .
Which of these will throw a SyntaxError?
A)
if (x == 1) { }
B)
if (x = 1) { }
C)
if (x ==== 1) { }
D)
if (x === 1) { }

Correct Answer :  

if (x ==== 1) { }

45 .
How do you check what the type of a value in variable x is?
var x = { ftl: "bar" }
A)
x._type;
B)
gettype(x);
C)
Object.type(x);
D)
type(x);

Correct Answer :   type(x);

46 .
Which of the following is not a reserved word in JavaScript?
A)
interface
B)
throws
C)
program
D)
short

Correct Answer :   program

47 .
What is the result of the below JavaScript code when the functions get called in the order as mentioned?

function first() {
    window.a = 3;
}

function second() {
    alert(a);
}​
A)
0
B)
3
C)
undefined
D)
null

Correct Answer :   3

48 .
Why so JavaScript and Java have similar name?
A)
JavaScript is a stripped-down version of Java
B)
JavaScript's syntax is loosely based on Java's
C)
They both originated on the island of Java
D)
None of the above

Correct Answer :   JavaScript's syntax is loosely based on Java's

49 .
How do you create an object in JavaScript?
A)
var obj = {};
B)
function Foo() {} var obj = new Foo();
C)
var obj = new Object();
D)
All of these work

Correct Answer :   All of these work

50 .
When a user views a page containing a JavaScript program, which machine actually executes the script?
A)
The User's machine running a Web browser
B)
A central machine deep within Netscape's corporate offices
C)
The Web server
D)
None of the above

Correct Answer :   The User's machine running a Web browser

51 .
What is the result of the following statement: typeof “x”;
A)
“character”
B)
“[object String]”
C)
“string”
D)
“undefined”

Correct Answer :   “string”

52 .
____ JavaScript is also called client-side JavaScript.
A)
Navigator
B)
LiveWire
C)
Microsoft
D)
Native

Correct Answer :   Navigator

53 .
Primitive types are passed by :
A)
Reference
B)
Value
C)
Pointer
D)
None of the above

Correct Answer :   Value

54 .
Which is not a primitive data type in JavaScript?
A)
boolean
B)
number
C)
string
D)
character

Correct Answer :   character

55 .
_______ JavaScript is also called server-side JavaScript.
A)
Navigator
B)
LiveWire
C)
Microsoft
D)
Native

Correct Answer :   LiveWire

56 .
Which of these is a correct method to create a new array?
A)
var myArray = ();
B)
var myArray = [];
C)
var myArray = new Array[];
D)
var myArray = {};

Correct Answer :   var myArray = [];

57 .
What are variables used for in JavaScript Programs?
A)
Storing numbers, dates, or other values
B)
Causing high-school algebra flashbacks
C)
Varying randomly
D)
None of the above

Correct Answer :   Storing numbers, dates, or other values

58 .
To what type are values converted internally when evaluating a conditional statement?
A)
positive
B)
negative
C)
integer
D)
boolean

Correct Answer :   boolean

59 .
Which of these is not a logical operator?
A)
!
B)
&
C)
&&
D)
||

Correct Answer :   &

60 .
_____ JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation.
A)
Client-side
B)
Server-side
C)
Local
D)
Native

Correct Answer :   Client-side

61 .
Which of the following can't be done with client-side JavaScript?
A)
Validating a form
B)
Sending a form's contents by email
C)
Storing the form's contents to a database file on the server
D)
None of the above

Correct Answer :   Storing the form's contents to a database file on the server

62 .
Which of the following way can be used to indicate the LANGUAGE attribute?
A)
<LANGUAGE="JavaScriptVersion">
B)
<SCRIPT LANGUAGE="JavaScriptVersion">
C)
<SCRIPT LANGUAGE="JavaScriptVersion">    JavaScript statements…</SCRIPT>
D)
None of the above

Correct Answer :  

<SCRIPT LANGUAGE="JavaScriptVersion">    JavaScript statements…</SCRIPT>

63 .
What is the value of x? var a = false; var x = a ? “A” : “B”;
A)
“A”
B)
“B”
C)
true
D)
false

Correct Answer :   “B”

64 .
What is the correct syntax for referring to an external script called " abc.js"?
A)
<script href=" abc.js">
B)
<script name=" abc.js">
C)
<script src=" abc.js">
D)
None of the above

Correct Answer :   <script src=" abc.js">

65 .
Which of the following variable types does not exist in JavaScript?
A)
boolean
B)
number
C)
object
D)
double

Correct Answer :   double

66 .
Which types of image maps can be used with JavaScript?
A)
Server-side image maps
B)
Client-side image maps
C)
Both (A) and (B)
D)
None of the above

Correct Answer :   Client-side image maps

67 .
How do you write a conditional statement that will *only* execute the contained code if variable x has a value 5 of type *number*?
A)
if (x == 5) { … }
B)
if x = 5 …
C)
if (x === 5) { … }
D)
if x = 5 then …

Correct Answer :   if (x === 5) { … }

68 .
Which of the following navigator object properties is the same in both   Netscape and IE?
A)
navigator.appCodeName
B)
navigator.appName
C)
navigator.appVersion
D)
None of the above

Correct Answer :   navigator.appCodeName

69 .
Which event fires whenever a control loses focus?
A)
onclick
B)
onmove
C)
onblur
D)
onchange

Correct Answer :   onblur

70 .
What does the <noscript> tag do?
A)
Enclose text to be displayed by non-JavaScript browsers.
B)
Prevents scripts on the page from executing.
C)
Describes certain low-budget movies.
D)
None of the above

Correct Answer :   Enclose text to be displayed by non-JavaScript browsers.

71 .
JavaScript entities start with _______ and end with _________.
A)
Semicolon, colon
B)
Ampersand, semicolon
C)
Semicolon, Ampersand
D)
Ampersand, colon

Correct Answer :   Ampersand, semicolon

72 .
Which of the following best describes JavaScript?
A)
a low-level programming language.
B)
a scripting language precompiled in the browser.
C)
a compiled scripting language.
D)
an object-oriented scripting language.

Correct Answer :   an object-oriented scripting language.

73 .
Which of the following invokes a user-defined object constructor function?
A)
var x = new myConstructor();
B)
var x = create myConstructor();
C)
myConstructor x = create myConstructor();
D)
myConstructor x = new myConstructor();

Correct Answer :   var x = new myConstructor();

74 .
Choose the server-side JavaScript object?
A)
FileUpLoad
B)
Function
C)
File
D)
Date

Correct Answer :   File

75 .
Choose the client-side JavaScript object?
A)
FileUpLoad
B)
Database
C)
Cursor
D)
Client

Correct Answer :   FileUpLoad

76 .
How is an object property referenced?
A)
myObj(foo)
B)
myObj->foo
C)
myObj<foo>
D)
myObj.foo

Correct Answer :   myObj.foo

77 .
Which of these operators compares two variables by value AND type?
A)
=
B)
==
C)
===
D)
None of the above

Correct Answer :   ===

78 .
Which of the following is not considered a JavaScript operator?
A)
new
B)
this
C)
delete
D)
typeof

Correct Answer :   this

79 .
Which of the following asserts that the variables `A`, `B`, and `C` have unequal values?
A)
A !== B || B !== C
B)
A !== B & B !== C
C)
A !== B && B !== C && A !== C
D)
A !== B

Correct Answer :   A !== B && B !== C && A !== C

80 .
The “if” statement is used to:
A)
Deal with logic that should execute only when a condition is false
B)
Convert an integer value to a boolean
C)
Create a loop that runs as long as a condition is true
D)
Deal with logic that should execute only when a condition is true

Correct Answer :   Deal with logic that should execute only when a condition is true

81 .
How to return the first value of this array? var myArr = [1, 2, 3, 4, 5]; var myVal = …
A)
myArr[0];
B)
myArr.pop();
C)
myArr[1];
D)
myArr.shift();

Correct Answer :   myArr[0];

82 .
Which of the following event fires when the form element loses the focus: <button>, <input>, <label>, <select>, <textarea>?
A)
onfocus
B)
onblur
C)
onclick
D)
ondblclick

Correct Answer :   onblur

83 .
The syntax of Eval is __________
A)
[objectName.]eval(numeriC.
B)
[objectName.]eval(string)
C)
[EvalName.]eval(string)
D)
[EvalName.]eval(numeriC.

Correct Answer :   [objectName.]eval(string)

84 .
Which of the following is the structure of an if statement?
A)
if (conditional expression is true) thenexecute this codeend if
B)
if (conditional expression is true)execute this codeend if
C)
if (conditional expression is true)   {then execute this code>->}
D)
if (conditional expression is true) then {execute this code}

Correct Answer :   if (conditional expression is true)   {then execute this code>->}

85 .
Which of these will throw a SyntaxError?
A)
if (x = 1) { }
B)
if (x == 1) { }
C)
if (x === 1) { }
D)
if (x ==== 1) { }

Correct Answer :   if (x ==== 1) { }

86 .
How do you define a function called “fName”?
A)
function fName: { }
B)
func fName = function () {}
C)
function fName() { }
D)
new fName = { }

Correct Answer :   function fName() { }

87 .
To set up the window to capture all Click events, we use which of the following statement?
A)
window.captureEvents(Event.CLICK);
B)
window.handleEvents (Event.CLICK);
C)
window.routeEvents(Event.CLICK );
D)
window.raiseEvents(Event.CLICK );

Correct Answer :   window.captureEvents(Event.CLICK);

88 .
To open a dialog box each time an error occurs, which of the following is added to prefs.js?
A)
user_pref("javascript.classic.error_alerts", true);
B)
user_pref("javascript.classic.error_alerts ", false);
C)
user_pref("javascript.console.open_on_error ", true);
D)
user_pref("javascript.console.open_on_error ", false);

Correct Answer :   user_pref("javascript.classic.error_alerts", true);

89 .
Which statement loops through an array?
A)
A. for (i < myArray.length; i++)
B)
for (i = 0; i <= myArray.length;)
C)
for (var i=0; i < myArray.length; i++)
D)
None of the above

Correct Answer :   for (var i=0; i < myArray.length; i++)

90 .

What is output ?

<script language="javascript">
	function x()
	{
	document.write(2+5+"8");
	}
</script>
A)
7
B)
78
C)
258
D)
Error

Correct Answer :   78

91 .
What is the value of the array myArr after execution of the following code: var myArr = [1,2,3,4,5]; myArr.shift();
A)
[1,2,3,4]
B)
[2,3,4,5]
C)
[1,2,3,4,5]
D)
None of the above

Correct Answer :   [2,3,4,5]

92 .
What is the difference between == and === ?
A)
The == is used in comparison, and === is used in value assignment.
B)
The == operator converts both operands to the same type, whereas === returns false for different types.
C)
The === is deprecated, and now they are exactly the same.
D)
None of the above

Correct Answer :   The == operator converts both operands to the same type, whereas === returns false for different types.

93 .
Which is the correct syntax to write array literals in JavaScript?
A)
var x = [“blank”,”blank”,”blank”];
B)
var x = array(“blank”, “blank”, “blank”);
C)
var x = {“blank”,”blank”,”blank”};
D)
var x = new Array(1:”blank”,2:”blank”,3:”blank”)

Correct Answer :   var x = [“blank”,”blank”,”blank”];

94 .
In JavaScript, to call a function directly, you use:
A)
function_expression { arguments_if_any }
B)
function_expression -> ( arguments_if_any )
C)
function_expression ( arguments_if_any )
D)
arguments_if_any ( function_expression )

Correct Answer :   function_expression ( arguments_if_any )

95 .
How do you assign object properties?
A)
obj(age) = 25 OR obj.age = 25
B)
obj[“age”] = 25 OR obj.age = 25
C)
obj.age = 25 OR obj(@”age”) = 25
D)
None of the above

Correct Answer :   obj[“age”] = 25 OR obj.age = 25

96 .
How do you assign an anonymous function to a variable?
A)
var anon = new Function () { };
B)
var anon = function() { };
C)
var anon = func() { };
D)
var anon = func({});

Correct Answer :   var anon = function() { };

97 .
var data = [“A”, “B”, “C”, “D”]; data.unshift(“X”); data.push(“Y”); What does data look like?
A)
[“A”, “B”, “C”, “X”, “D”, “Y”]
B)
[“X”, “Y”, “A”, “B”, “C”, “D”]
C)
[“X”, “A”, “B”, “C”, “D”, “Y”]
D)
[“A”, “B”, “C”, “D”, “X”, “Y”]

Correct Answer :   [“X”, “A”, “B”, “C”, “D”, “Y”]

98 .
Which has the correct syntax of a ternary operation?
A)
var x = ( y === true ) { “true” : “false” };
B)
var x = y === true ? “true” : “false”;
C)
var x = y === true : “true” ? “false”;
D)
var x = ( y === true ) : “true” ? “false”;

Correct Answer :   var x = y === true ? “true” : “false”;

99 .
What is the name of the String prototype that appends the given string to the base string and returns the new string?
A)
“x”.combine(“foo”)
B)
“x”.match(“foo”)
C)
“x”.add(“foo”)
D)
“x”.concat(“foo”)

Correct Answer :   “x”.concat(“foo”)

100 .
What are curly braces (“{” and “}”) used for?
A)
Parsing JSON
B)
Defining a class
C)
Block declarations and object literals
D)
Setting attributes

Correct Answer :   Block declarations and object literals

101 .
Which of the following is not a method in the “JSON” object according to the ECMAScript specification?
A)
JSON.stringify
B)
JSON.fromString
C)
JSON.parse
D)
None of the above

Correct Answer :   JSON.fromString

102 .
Which of the following is the correct statement of WHILE loop start?
A)
while (i <= 10)
B)
while (i <= 10; i++)
C)
while i = 1 to 10
D)
None of the above

Correct Answer :   while (i <= 10)


Explanation : while (i <= 10) is the correct statement of WHILE loop start.

103 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
  var x = 123e5;
  document.getElementById("demo").innerHTML = x ;
</script>
A)
0.0123
B)
12300
C)
Error
D)
None of the above

Correct Answer :   12300

104 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
	function myFunction() {
   	var res = "";
   	res = res + Number.isInteger('123');
   	document.getElementById("demo").innerHTML = res;
	}
</script>
A)
True
B)
False
C)
Error
D)
Undefined

Correct Answer :   False

105 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
function myFunction() {
     var res = "";
     res = res + Number.isInteger(0.5) + ": 0.5<br>";
     document.getElementById("demo").innerHTML = res;
 }
</script>
A)
True
B)
False
C)
Error
D)
Undefined

Correct Answer :   False

106 .
What will be the output of the following JavaScript code if oddsums(5); is executed after the following code snippet?
 
function oddsums(n) {
     let total = 0, result=[]; 
     for(let x = 1; x <= n; x++) 
     { 
        let odd = 2*x-1; 
        total += odd;
        result.push(total);
     }
     return result;
 }
A)
Returns [1,4,9,16,25]
B)
Returns [1,2,3,4,5]
C)
Returns [3,6,9,12,15]
D)
Returns [1,3,5,7,9]

Correct Answer :   Returns [1,4,9,16,25]

107 .
What would be the result or type of error if p is not defined in the following JavaScript code snippet?
console.log(p)
A)
Zero
B)
Null
C)
Reference Error
D)
Value not found Error

Correct Answer :   Reference Error

108 .
What will be the output of the following JavaScript code?
let x=x+1;
console.log(x);
A)
0
B)
Null
C)
Error
D)
NaN

Correct Answer :   NaN

109 .
Which method of the iterable object returns an iterator object for the collection?
A)
iterator()
B)
_iterator_()
C)
_iteration_()
D)
_return_iterator_()

Correct Answer :   _iterator_()

110 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
	function myFunction() {
   	var res = "";
   	res=res + Number.isSafeInteger(Math.pow(2, 53)-1)+": 2<sup>53</sup>-1<br>";
   	document.getElementById("demo").innerHTML = res;
	}
</script>
A)
True
B)
False
C)
Error
D)
Undefined

Correct Answer :   True

111 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
     function myFunction() {
  	 document.getElementById("demo").innerHTML = Number.MAX_VALUE;
    }
</script>
A)
1.7976931348623157e+305
B)
1.7976931348623157e+307
C)
1.7976931348623157e+308
D)
Error

Correct Answer :   1.7976931348623157e+308

112 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
  function myFunction() {
     document.getElementById("demo").innerHTML = Number.NEGATIVE_INFINITY;
  }
</script>
A)
-1000
B)
-infinity
C)
infinity
D)
undefined

Correct Answer :   -infinity

113 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
  function myFunction() {
     var num = 5.56789;
     var n = num.toExponential();
     document.getElementById("demo").innerHTML = n;
 }
</script>
A)
5.56789e+0
B)
5.568e+0
C)
5.57e+0
D)
Error

Correct Answer :   5.56789e+0

114 .
What will be the output of the following JavaScript code?
function printArray(a) {
     var len = a.length, i = 0;
     if (len == 0)
        console.log("Empty Array");
     else 
     {
         do 
         {
             console.log(a[i]);
         } while (++i < len);
     }
}
A)
Prints the numbers in the array in order
B)
Prints the numbers in the array in the reverse order
C)
Prints 0 to the length of the array
D)
Prints “Empty Array”

Correct Answer :   Prints the numbers in the array in order

115 .
What will be the role of the continue keyword in the following JavaScript code snippet?
while (a != 0){
   if (a == 1) 
       continue;
   else 
       a++;
}
A)
The continue keyword restarts the loop
B)
The continue keyword skips the next iteration
C)
The continue keyword skips the rest of the statements in that iteration
D)
The continue keyword breaks out of the loop

Correct Answer :   The continue keyword skips the rest of the statements in that iteration

116 .
What will be the output of the following JavaScript code?
function range(int length){
	int a=5;
	for(int i=0;i<length;i++)
	{
		console.log(a);
	} 
}
range(3);
A)
3
B)
5
C)
555
D)
error

Correct Answer :   555

117 .
What will be the output of the following JavaScript code?
var a = 10;
   do {
  	a += 1;
  	console.log(a);
   } while (a < 5);
A)
11
B)
1112
C)
12345
D)
11121314

Correct Answer :   11

118 .
What will be the output of the following JavaScript code?
function printArray(a) 
{
     var len = a.length, i = 0;
     if (len == 0)
        console.log("Empty Array");
     else 
     {
         do 
         {
             console.log(a[i]);
         } while (++i < len);
     }
}
A)
Prints the numbers in the array in order
B)
Prints the numbers in the array in the reverse order
C)
Prints 0 to the length of the array
D)
Prints “Empty Array”

Correct Answer :   Prints the numbers in the array in order

119 .
What will be the output of the following JavaScript statement?
var grand_Total=eval("10*10+5");
A)
10*10+5
B)
105 as a string
C)
105 as an integer value
D)
Exception is thrown

Correct Answer :   105 as an integer value

120 .
Will the following JavaScript code work?
var tensquared = (function(x) {return x*x;}(10));
A)
Yes, perfectly
B)
Memory leak
C)
Error
D)
Exception will be thrown

Correct Answer :   Yes, perfectly

121 .
What will the following JavaScript code snippet work? If not, what will be the error?
function tail(o) { 
    for (; o.next; o = o.next) ;
    return o;
}
A)
No, this will throw an exception as only numerics can be used in a for loop
B)
No, this will result in a runtime error with the message “Cannot use Linked List”
C)
Yes, this will work
D)
No, this will not iterate

Correct Answer :   Yes, this will work

122 .
What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?
A)
The property will be stored in a cache
B)
That property will not be enumerated
C)
The loop will not run
D)
The property will be enumerated

Correct Answer :   That property will not be enumerated

123 .
What will be the equivalent statement of the following JavaScript statement?
var o = new Object();​
A)
var o= new Object;
B)
var o = Object();
C)
Object o=new Object();
D)
var o;

Correct Answer :   var o= new Object;

124 .
What will be the last statement return in the following JavaScript code?
function constfuncs() {
    var funcs = [];
    for(var i = 0; i < 10; i++)
        funcs[i] = function() { return i; };
    return funcs;
}
var funcs = constfuncs();
funcs[5]()
A)
0
B)
9
C)
10
D)
11

Correct Answer :   10

125 .
What will be the output of the following JavaScript code?
var arr = [7, 5, 9, 1];  
var min = Math.min.apply(null, arr);  
document.writeln(min);
A)
1
B)
5
C)
7
D)
9

Correct Answer :   1

126 .
What will be the output of the following JavaScript code?
var a= 0;
var b = 0;
while (a < 3)
{
  	a++;
  	b += a;
	console.log(b);
}
A)
01
B)
013
C)
123
D)
135

Correct Answer :   135

127 .
What will be the output of the following JavaScript code?
var a=3.7;
var b=2;
a=ciel(a)
document.writeIn(a*b);
A)
6
B)
7.5
C)
8
D)
None of the above

Correct Answer :   8

128 .
What will be the output of the following JavaScript code if oddsums(5); is executed after the following code snippet?
function oddsums(n) {
     let total = 0, result=[]; 
     for(let x = 1; x <= n; x++) 
     { 
        let odd = 2*x-1; 
        total += odd;
        result.push(total);
     }
     return result;
}
A)
Returns [1,2,3,4,5]
B)
Returns [1,4,9,16,25]
C)
Returns [3,6,9,12,15]
D)
Returns [1,3,5,7,9]

Correct Answer :   Returns [1,4,9,16,25]

129 .
Which is the correct code that returns a complex number that is the complex conjugate of this one?
A)
Complex.prototype.conj = function() { return new Complex(this.r, -this.i); };
B)
Complex.prototype.conj = function() { return Complex(this.r, -this.i); };
C)
Complex.prototype.conj = function() { return (this.r, -this.i); };
D)
Complex.prototype.conj = function() { new Complex(this.r, -this.i); };

Correct Answer :   Complex.prototype.conj = function() { return new Complex(this.r, -this.i); };

130 .
What convenience does the following JavaScript code snippet provide?
let succ = function(x) x+1, yes = function() true, no = function() false;
A)
Functional behaviour
B)
Modular behaviour
C)
Shorthand expression
D)
No convenience

Correct Answer :   Functional behaviour

131 .
Consider the following JavaScript statement containing regular expressions and check if the pattern matches?
var text = "testing: 1, 2, 3"; 
var pattern = /\d+/g;
A)
text==pattern
B)
text.equals(pattern)
C)
text.test(pattern)
D)
pattern.test(text)

Correct Answer :   pattern.test(text)

132 .
What does /[^(]* regular expression indicate?
A)
Match one or more characters that are not open parenthesis
B)
Match zero or more characters that are open parenthesis
C)
Match zero or more characters that are not open parenthesis
D)
Match one or more characters that are open parenthesis

Correct Answer :   Match zero or more characters that are not open parenthesis

133 .
What will be the purpose of exec() in the following JavaScript code?
var pattern = /Java/g;
    var text = "JavaScript is more fun than Java!";
    var result;
    while ((result = pattern.exec(text)) != null) {
        alert("Matched '" + result[0] + "'" +" at position " + result.index +"; 
              next search begins at " + pattern.lastIndex);
    }
A)
Returns different arrays in the different turns of iterations
B)
Returns the same kind of array whether or not the regular expression has the global g flag
C)
Return a sub part of the array
D)
Returns a null value

Correct Answer :   Returns the same kind of array whether or not the regular expression has the global g flag

134 .
What will be the output of the following JavaScript code?
 System.out.println(Pattern.matches("\\d", "1"));
A)
True
B)
False
C)
Error
D)
None of the above 

Correct Answer :   True

135 .
What is the code to be used to trim whitespaces?
A)
let trimmed = l.trim();
B)
let trimmed = (trim(l));
C)
let trimmed = (l.trim() for (l in lines));
D)
let trimmed = for(l in lines));

Correct Answer :   let trimmed = (l.trim() for (l in lines));

136 .
What will be the output of the following JavaScript code?
 
<p id="demo"></p>
<script>
   var x = 10;
   var y = "20";
   var z = x + y;
   document.getElementById("demo").innerHTML = z;
</script>
A)
30
B)
10 20
C)
1020
D)
Error

Correct Answer :   1020

137 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
  var x = 9.656;
  document.getElementById("demo").innerHTML =
  x.toFixed(0)
</script>
A)
9.6
B)
9.65
C)
9.656
D)
10

Correct Answer :   10

138 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
function myFunction() {
     document.getElementById("demo").innerHTML = Math.trunc(8.76);
}
</script>
A)
8.00
B)
8.70
C)
8.76
D)
Error

Correct Answer :   8.00

139 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
function myFunction() {
     document.getElementById("demo").innerHTML = Math.LN10;
}
</script>
A)
2.00
B)
2.10
C)
2.20
D)
2.30

Correct Answer :   2.30

140 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
  function myFunction() {
     document.getElementById("demo").innerHTML = Math.acosh(2);
  }
</script>
A)
1.11
B)
1.20
C)
1.31
D)
1.41

Correct Answer :   1.31

141 .
What will be the output of the following JavaScript code?
function emp(name,salary){  
     this.name=name;  
     this.salary=salary;  
 
     this.changeSalary=changeSalary;  
     function changeSalary(otherSalary)
     {  
         this.salary=otherSalary;  
     }  
}  
e=new emp("FTL",30000);  
e.changeSalary(45000);  
document.write("e.name+" "+e.salary);
A)
FTL 30000
B)
FTL 45000
C)
FTL
D)
45000

Correct Answer :   FTL 45000

142 .
What will be the output of the following JavaScript code?
const obj = { 10: 'arry', 21: 'barry', 23: 'carry' };  
console.log(Object.entries(obj)[2]);
A)
[“arry”, “10”]
B)
[“10”,”arry”]
C)
[“21”,barry”]
D)
[“23”,”carry”]

Correct Answer :   [“23”,”carry”]

143 .
What will be the output of the following JavaScript code?
document.writeln("<br/>navigator.appCodeName: "+navigator.appCodeName);
A)
Browser name
B)
Version
C)
Error
D)
Undefined

Correct Answer :   Browser name

144 .
What will be the output of the following JavaScript code?
document.writeln("<br/>navigator.language: "+navigator.language);
A)
Browser language
B)
Broswer name
C)
Browser version
D)
Error

Correct Answer :   Browser version

145 .
When the “end” event fires on EOF when no more data will arrive, which function is called?
A)
s.on(“data”,f);
B)
s.on(“end”,f);
C)
s.on(“error”,f);
D)
s.on(“default”,f);

Correct Answer :   s.on(“end”,f);

146 .
Which function is a synonym for on()?
A)
add()
B)
once()
C)
listeners()
D)
addListener()

Correct Answer :   addListener()

147 .
What will be the output of the following JavaScript code?
<p id="demo">Free Time Learning</p>
<script>
function myFunction() {
   var text = document.getElementById("demo").innerHTML;
   document.getElementById("demo").innerHTML = text.toUpperCase();
}
</script>
A)
Free Time Learning
B)
FREE TIME LEARNING
C)
free time learning
D)
Error

Correct Answer :   FREE TIME LEARNING

148 .
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
  Var arr = ["one", "two", "three",];
  arr.shift();
  document.getElementById("demo").innerHTML = arr;
</script>
A)
two three
B)
one two
C)
one three
D)
None of the above

Correct Answer :   two three

149 .
The libraries that build a new higher-level API for client-side programming is _____
A)
Library
B)
Framework
C)
APIs
D)
Script

Correct Answer :   Framework

150 .
Which of the following frameworks focuses on DOM and Ajax utilities?
A)
jQuery
B)
Prototype
C)
Dojo
D)
Both jQuery and Prototype

Correct Answer :   Both jQuery and Prototype

151 .
Which function among the following lets to register a function to be invoked once?
A)
setTimeout()
B)
setTotaltime()
C)
setInterval()
D)
settime()

Correct Answer :   setTimeout()

152 .
Which method receives the return value of setInterval() to cancel future invocations?
A)
clearInvocation()
B)
clearInterval()
C)
cancelInvocation()
D)
clear()

Correct Answer :   clearInterval()

153 .
What will be the output of the following JavaScript code?
function getcube(){  
    var number=document.getElementById("number").value;  
    alert(number*number*number);  
}
<form>  
     Enter No:<input type="text" id="number" value="3" name="number"/><br/>  
     <input type="button"  value="ok" onclick="getcube()"/>  
</form>
A)
9
B)
27
C)
45
D)
None of the above

Correct Answer :   27

154 .
How are windows, tabs, iframes, and frames treated according to client-side javascript?
A)
They are all browsing contexts
B)
They are all browsing information
C)
They are all Window contexts
D)
They are all Window objects

Correct Answer :   They are all browsing contexts

155 .
A new web browser window can be opened using which method of the Window object?
A)
createtab()
B)
open()
C)
create()
D)
Window.open()

Correct Answer :   Window.open()

156 .
DOM Level 3 Events standardizes which of the following events?
A)
focusarea and focusover
B)
focusall and focusnone
C)
focusdown and focusup
D)
focusin and focusout

Correct Answer :   focusin and focusout

157 .
Which property holds a DataTransfer object that contains information about the data being transferred and the formats in which it is available?
A)
dataTransfer
B)
transferData
C)
dataExchange
D)
exchangeData

Correct Answer :   dataTransfer

158 .
Which of the following uses scripted HTTP?
A)
XML
B)
HTML
C)
CSS
D)
Ajax

Correct Answer :   Ajax

159 .
Which of the below is a liberal reverse of Ajax?
A)
HTTP
B)
HTML
C)
XML
D)
Comet

Correct Answer :   Comet

160 .
Which is the appropriate code to begin a HTTP GET request?
A)
request.open(“GET”,”data”);
B)
request.open(GET,”data.csv”);
C)
request.open(“GET”,”data.csv”);
D)
request.open(“GET”);

Correct Answer :   request.open(“GET”,”data.csv”);

161 .
What is the programming philosophy that argues that content and behaviour should as much as possible be kept separate?
A)
Unobtrusive JavaScript
B)
Obtrusive JavaScript
C)
Inherited JavaScript
D)
Modular JavaScript

Correct Answer :   Unobtrusive JavaScript

162 .
Which of the following is not an advanced services?
A)
Data storage
B)
Networking
C)
XMLHttpRequest object
D)
Graphics APIs

Correct Answer :   Graphics APIs

163 .
What is the initial step to set up a CSS Lazy Loading?
A)
Loading the page
B)
Loading the script
C)
Fetching data
D)
Adding the event listener

Correct Answer :   Fetching data

164 .
What is being done in the following JavaScript code?
<script>
if (window.attachEvent)
window.attachEvent('onload', fetch);
else
window.addEventListener('load', fetch, false);
</script>
A)
Event and EventListener is created according to the if-else
B)
The values are updated
C)
The value is called
D)
The values are stored

Correct Answer :   Event and EventListener is created according to the if-else

165 .
What is the parameter of the method getElementsbyTagName() if we need to get an image?
A)
image
B)
img
C)
src
D)
imageurl

Correct Answer :   img

166 .
Where is the external JavaScript placed in the case of lazy loading?
A)
After window.onload event
B)
Before window.onload event
C)
In the header tag
D)
In the HTML tag

Correct Answer :   After window.onload event

167 .
What is the purpose of the domLoading attribute?
A)
Document exists
B)
Document can load
C)
Document has loaded
D)
Document begins to load

Correct Answer :   Document begins to load

168 .
You can refresh the webpage in JavaScript by using _______
A)
window.reload
B)
window.refresh
C)
location.reload
D)
page.refresh

Correct Answer :   location.reload

169 .
Which is the function that is called to validate a data?
A)
validate()
B)
valid()
C)
validation()
D)
no predefined function for data validation

Correct Answer :   no predefined function for data validation