R4RIN
Articles
Java 8
MCQS
JavaScript MCQ Quiz Hub
JAVASCRIPT MCQ
Choose a topic to test your knowledge and improve your JavaScript skills
1. Which of the following is correct about JavaScript?
JavaScript is a lightweight, interpreted programming language.
JavaScript has object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.
The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers.
All of the above
2. Which of the following is the correct syntax to print a page using JavaScript?
window.print();
browser.print();
navigator.print();
document.print();
3. Which of the following type of variable is visible only within a function where it is defined?
global variable
local variable
Both of the above.
None of the above
4. Which built-in method returns the calling string value converted to upper case?
toUpperCase()
toUpperCase()
changeCase(case)
None of the above
5. Which of the following function of Number object returns the number's value?
toString()
valueOf()
toLocaleString()
toPrecision()
6. Which of the following function of String object returns the index within the calling String object of the first occurrence of the specified value?
substr()
search()
lastIndexOf()
indexOf()
7. Which of the following function of String object creates an HTML anchor that is used as a hypertext target?
anchor()
link()
blink()
big()
8. Which of the following function of String object causes a string to be displayed as struck-out text, as if it were in a strike tag?
sup()
small
strike()
sub()
9. Which of the following is true about variable naming conventions in JavaScript?
You should not use any of the JavaScript reserved keyword as variable name.
JavaScript variable names should not start with a numeral (0-9).
Both of the above.
None of These
10. Which of the following is the correct syntax to redirect a url using JavaScript?
document.location='http://www.newlocation.com';
browser.location='http://www.newlocation.com';
navigator.location='http://www.newlocation.com';
window.location='http://www.newlocation.com';
11. Which of the following function of String object returns a number indicating the Unicode value of the character at the given index?
charAt()
charCodeAt()
concat()
indexOf()
12. Which of the following function of String object executes the search for a match between a regular expression and a specified string?
concat()
match()
replace()
search()
13. Which of the following function of String object returns the calling string value converted to upper case while respecting the current locale?
toLocaleUpperCase()
toUpperCase()
toString()
substring()
14. Which of the following is a valid type of function javascript supports?
named function
anonymous function
Both of the above
None of the above
15. How can you get the type of arguments passed to a function?
using typeof operator
using getType function
Both of the above.
None of the above
16. Which of the following function of Array object removes the first element from an array and returns that element?
reverse()
shift()
slice()
some()
17. ....................... is a built - in JavaScript function which can be used to execute another function after a given time interval.
Timeout( )
TimeInterval( )
setTimeout ( )
All of the above
18. Java Script entities start with ___________and end with _____________.
Semicolon, colon
Semicolon, Ampersand
Ampersand, colon
Ampersand, semicolon
19. Which of the following is a server-side Java Script object?
Function
File
FileUpload
Date
20. Javascript is _________ language.
Programming
Application
Scripting
None of These
21. JavaScript is ______ Side Scripting Language.
Server
ISP
Browser
None of the these
22. Cost for Using JavaScript in your HTML is _________ .
Its Free !!!
$10 / Year
$15 / Year
$5 / Year
23. JavaScript Code is written inside file having extension __________.
.jvs
.javascript
.js
.jsc
24. Why JavaScript is called as Lightweight Programming Language ?
because JS is available free of cost
because JS is client side scripting
because we can add programming functionality inside JS
because JS can provide programming functionality inside but up to certain extend
25. Local Browser used for validations on the Web Pages uses __________.
Java
CSS
HTML
JS
26. State the correct place of JS Code inside HTML -
Inside Body
Inside Head
Inside Single JavaScript File
All of these
27. Which of the following Attribute is used to include External JS code inside your HTML Document ?
link
script
ext
ext
28. Which attribute is used to specifies that the script is executed when the page has finished parsing (only for external scripts) ?
type
defer
async
parse
29. ______ attribute is used to specify the character encoding used in an external script file.
type
charset
character
None of These
30. The async attribute can be set in the following ways -
<script async>
<script async="">
<script async="async">
All of the these
31. We use _______ style comment to prevent showing Java Script as Content in the old browsers.
JS
CSS
HTML
C
32. What will be the Output of the below Code ? <html> <body> <script type="text/javascript"> <!-- document.print("Hello"); //--> </script> </body> </html>
Will Throw Error
Hello
Will not print anything because of Comment
None of These
33. Which was the first browser to support JavaScript ?
Mozilla Firefox
Google Chrome
IE
Netscape
34. JavaScript is invented by ________.
Brendan Eich
Helsinki, Linus
W3 Group
James Gosling
35. JavaScript was invented at _______ Lab .
Netscape
Google Lab
AT&amp;T Bell Lab
Sun Microsystem
36. JavaScript was originally developed under the name _______.
ActionScript
Mocha
Oak
Sencha
37. In March 1996, _______________ was released, featuring support for JavaScript.
Netscape Navigator 1.0
Internet Explorer 2.0
Netscape Navigator 2.0
Internet Explorer 1.0
38. Microsoft Developed a compatible dialect of JavaScript called _____________.
JScript
MS JavaScript
MJavaScript
Advanced JavaScript
39. Executable single line of Script is called as _________________.
Statement in JavaScript
Breakpoint in JS
Line in JS
None of These
40. JavaScript Statements are executed by ________ .
Server
JVM
Compiler
Browser
41. 43. Java Statement terminated by ______________ .
Slash
Semicolon
Full Stop
Comma
42. JavaScript code contain sequence of ___________.
HTML Tags
Method Calls
Executable Statements
All of the these
43. Which of the following statement is used to declare variable in JavaScript ?
Assignment Statement
Conditional Statement
Executable Statement
Declaration Statement
44. ____________ is used to assign value to the variable.
Assignment Statement in JavaScript
Declaration Statement
Conditional Statement
Executable Statement
45. What will be printed inside webpage ? var message="Hello JS"; document.write(Message);
It will crash browser since No Error handler is provided
Hello JS
&quot;Hello JS&quot; will be printed multiple times
Nothing Will be printed because Code is not error free
46. Multiple JS statements are written inside pair of ________ to form a statement block.
Pair of Square Brackets
Pair of Round Brackets
Pair of Curly braces
None of these
47. Below Code contain one executive Statement. Guess the Output of the Code. <script type="text/javascript"> { document.Write("<h1>This is a heading</h1>"); } </script>
&quot;This is a heading&quot; will be printed in H1 heading
Just &quot;This is a heading&quot; will be printed because HTML tags are not allowed
Will not print anything
None of these
48. Group of JavaScript Statements is called as _________
Statement Block
Group
Cluster
Code Block
49. Single Line Comment in JavaScript Starts with _________ Symbol.
&quot;&quot;
&quot;//&quot;
&quot;$$&quot;
&quot;#&quot;
50. Which of the following is considered as End of Single line comment ?
End of Line
Semicolon
End of Statement
&quot;*/&quot; Symbol
51. Comments in JS are ignored by ____________.
Compiler
Operating System
JVM
Browser
52. Comment Statement is _________________ type of statement.
Executive
Non Important
Non Executable
Non Usable
53. JS Comment can be used for following purposes -
to Hide Non-usable line
to Hide Non-usable Multiline Code
used for Documentation
All of these
54. Which of the statement will be neglected by Browser ?
&lt;p&gt;Google&lt;/p&gt;
&lt;p&gt;Yahoo&lt;/p&gt;
&lt;h1&gt;Heading&lt;/h1&gt;
All Statements
55. Person XYZ wrote his name and date of code creation at the start , What kind of comment he has written ?
Functional Comment
Code Hiding Comment
Documentation Comment
None of These
56. Which of the following is not a compound assignment operator ?
===
&lt;&lt;=
+=
&gt;&gt;=
57. If a string cannot be converted to a number __________ will be returned.
NaN
Infinite
Null
Zero
58. If the values on either side of '+' operator are numerical values then ___________.
values are concatenated together
values are added together
no effect
None of These
59. What will be printed ? <html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- var A = "Compile ", B = "Error"; C = A + B; alert(C); // --> </script> </head> <body></body> </html>
&quot;Compile Error&quot; will be printed
&quot;Compile&quot; will be printed
Nothing will be printed
None of the above
60. What will be the value of Variable 'output' ? var str = "Str"; var num = 10; var output = str + num;
Nothing will be printed
Str10
Null
NaN
61. During addition of two numbers , suppose one of the number is NaN then output of the following code will be ?
NaN
Zero
Infinite
Null
62. +Infinity in JS gets added with +Infinity then output of the code will be
NaN
+Infinity
-Infinity
Null
63. -Infinity in JS gets added with -Infinity then output of the code will be
+Infinity
NaN
-Infinity
None of the above
64. Variable can hold ________ value at a time.
Multiple
Double
Single
None of These
65. Integer Variable is declared using following syntax in JavaScript.
Integer num;
var num;
int num;
integer num;
66. We can declare ___________ at a time. Select most appropriate option.
One Variable Only
One or more Variables
More than One Variables
None of these
67. We can declare all type of variables in JavaScript with the keyword __________
var
obj
jvar
None of these
68. We can declare all type of variables in JavaScript with the keyword _____________.
var
obj
jvar
None of These
69. var num; Above Statement is called as __________ Statement.
Instantization
Globalization
Declaration
Initialization
70. Variable name contain following type of characters - 1. Alphabet 2. Digits 3. Underscore 4. Special Characters Select the correct option.
3 4 2
4 3 1
1 2 3 4
1 2 3
71. Spaces,Punctuation marks are called as __________ Symbols in JavaScript.
Special
Punctual
Mandetory
None of these
72. Which JavaScript variable cannot be used as First character but can be use after first character ?
Asterisk
Dollar Sign
Underscore
Digit
73. Multiple Declarations of variables are separated by ___________ symbol.
Semicolon
Colon
Comma
Asterisk
74. var var1 = "Pritesh"; Above variable can store value of type -
Integer
String
Any Type
None of these
75. var var1 = "Pritesh"; Above variable can store value of type -
Integer
String
Any Type
None of These
Submit