JavaScript MCQ (Mulitple Choice Questions and Answers)
-
What is JavaScript?
scripting language
assembly language
compiled language
None of the mentioned
-
Which one of the following also known as Conditional Expression?
Alternative to if-else
Switch statement
If-then-else statement
immediate if
-
The "function" and " var" are known as?
Keywords
Data types
Declaration statements
Prototypes
-
A collection of elements of the same data type which may either in order or not, is called
String
Array
Serialized Object
Object
-
A set of unordered properties that, has a name and value is called
String
Array
Serialized Object
Object
-
Which HTML element is used to put the JavaScript code?
<javascript>
<js>
<scripting>
<script>
-
Which of the following is not a JavaScript Data Types?
Boolean
String
Float
Number
-
Which of the following syntax can be used to write "Hello World" in an alert box?
alertBox("Hello World");
msgBox("Hello World");
alert("Hello World");
msg("Hello World");
-
Which of the following is the correct way to write a comment in JavaScript code?
//This is a comment
/*This is a comment*/
$This is a comment$
**This is a comment**
-
Which of the following JavaScript operator is used to assign a value to a variable based on some condition?
Assignment operator
Bitwise Operator
Conditional operator
Logical Operator
-
Which of the following is Pop up box in JavaScript??
Alert
Prompt
Confirm
All of the above
-
Which of the following is the correct statement of WHILE loop start?
while (i <= 15)
while (i=0; i <= 15; i++)
while i = 1 to 15
None of These
-
What are the different types of errors in JavaScript?
Syntax errors
Run time errors
Logical Errors
All of the above
-
Which of the following built-in method is used to remove the last element from an array and return that element?
last()
pop()
get()
None of the above
-
What is the correct syntax for referring to an external script called : script.js"?
<script href="script.js">
<script name="script.js">
<script src="script.js">
None of the above
-
Which of the following is a error type in JavaScript?
Missing of Bracket
Division by zero
Syntax error
Missing of semicolons
-
JavaScript ignores?
spaces
tabs
new lines
All of the above
-
Can you access Cookie using javascript?
True
False
-
Which built-in method sorts the elements of an array?
changeOrder(order)
order()
sort()
None of the above
-
Which of the following function of String object returns the character at the specified index?
charAt()
charCodeAt()
concat()
indexOf()
-
Which of the following function of String object splits a String object into an array of strings by separating the string into substrings?
slice()
split()
replace()
search()
-
Among the keywords below, which one is not a statement?
if
with
else
use strict
-
Which of them is not the looping structures in JavaScript?
for
while
forwhile
dowhile
-
JavaScript is designed for following purpose
to style HTML pages
to execute Queries related to databases on a server
to add interactivity to html pages
All of the above
-
Which of the following is not a built-in function in JavaScript?
search()
concat()
add()
-
Javascript string using double quotes is exactly the same as a string using single quotes?
True
False
-
In JavaScript, Arrays are data type. State True or False
True
False
-
Which of the following method checks if its argument is not a number?
isNaN()
nonNaN()
NaN()
None of the above
-
Which method is used to add and/or remove elements from an array in Javascript?
Reverse
Shift
Slice
Splice
-
JavaScript can be written
directly into JS file and included into HTML
directly on the server page
directly into HTML pages
directly into the css file
-
How to get a particular value using the tagged name?
getElementbyID()
getElementsbyName()
getElementsbyTagName()
getTagName()
-
What is the original name of JavaScript?
LiveScript
EScript
Mocha
JavaScript
-
Which one is Ternary Operator?
?*
?:
>?
<?
-
Javascript is a which type of language
Interpreted
Compiled
-
Which of the following function of String object returns the characters in a string between two indexes into the string?
substr()
substring()
string()
count()
-
A function definition expression is known as
Function calls
Function definiation
Function calling
Function literal
-
The script must placed in
head
head and body
title and body
all of the mentioned
-
Which of the following attribute is used to include external js code inside your HTML document?
src
external
script
link
-
A proper scripting language is a
High level programming language
Assembly level programming language
Machinen level programming language
Low level programming language
-
Javascript code can be called by using
RMI
Triggering Event
Preprocessor
Function/Method
-
The snippet that has used to check if "a" is not equal to "null" is
if(a!=null)
if(a!)
if(a!null)
if(a!==null)
-
The property of primary expression is
stand-alone expressions
basic expressions containing all necessary functions
contains variable references alone
complex expressions
-
A statement block is a
conditional block
block that contains a single statement
Both conditional block and single statement
block that combines multiple statements into a single compound statement
-
When an empty statement encountered, javascript interpreter
Ignores the statement
Prompts to complete the statement
Throws an error
Throws an exception
-
The "var and "function" are
Declaration statements
Datatypes
Prototypes
-
What are the three important manipulations done in a for loop on a loop variable?
Updation, Incrementation, Initialization
Initialization,Testing, Updation
Testing, Updation, Testing
Initialization,Testing, Incrementation
-
Which of the following keywords is used to define a variable in Javascript?
var
fun
Both A and B
None of the above
-
Which of the following methods can be used to display data in some form using Javascript?
document.write()
console.log()
window.alert()
All of the above
-
How can a datatype be declared to be a constant type?
var
const
let
constant
-
What is the purpose of script loading?
Load JavaScript files manually
Load JavaScript files programmatically
Both A and B