Home

JavaScript MCQ Question with Answer

JavaScript MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Download JavaScript MCQ Question Answer PDF

Question No : 29
What will be the output of the following JavaScript code?

int a==2;
int b=4;
int ans=a+b;
print(ans);

2
6
0
error

Question No : 30
What will be the output of the following JavaScript code?

int a=1;
if(a!=null)
return 1;
else
return 0;

1
0
runtime error
compiler error

Question No : 31
What will be the output of the following JavaScript code?

var string1 = 123;
var intvalue = 123;
alert( string1 + intvalue );

123246
246
123123
Exception

Question No : 32
A function definition expression can be called as __________

Function prototype
Function literal
Function calling
Function declaration

Question No : 33
The property of a primary expression is ____________

stand-alone expressions
basic expressions containing all necessary functions
contains variable references alone
contains only keywords

Question No : 34
Consider the following JavaScript statements.

var text = testing: 1, 2, 3; // Sample text
var pattern = /d+/g // Matches all instances of one or more digits

In order to check if the pattern matches with the string text, the statement is ____________

text==pattern
text.equals(pattern)
text.test(pattern)
pattern.test(text)

Question No : 35
The expression of calling (or executing) a function or method in JavaScript is called ________

Primary expression
Functional expression
Invocation expression
Property Access Expression