Home

RBI Assistant - JavaScript 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. The script tag must be placed in __________
A. the head tag
B. the head or body
C. the title or head
D. after the body tag
Answer : B
2. What will be the output of the following JavaScript code?
function compare()
{
int num=2;
char b=2;
if(a==b)
return true;
else
return false;
}

A. true
B. false
C. runtime error
D. compilation error
Answer : A
3. What is the purpose of a return statement in a function?
A. Returns the value and continues executing rest of the statements, if any
B. Returns the value and stops the program
C. Returns the value and stops executing the function
D. Stops executing the function and returns the value
Answer : D
4. The enumeration order becomes implementation dependent and non-interoperable if ___________
A. If the object inherits enumerable properties
B. The object does not have the properties present in the integer array indices
C. The delete keyword is never used
D. Object.defineProperty() is not used
Answer : A
5. 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. 135
B. 123
C. 013
D. 01
Answer : A
6. What will be the output of the following JavaScript code?
Int a=1;
if(a>10)
{
document.write(10);
}
else
{
document.write(a);
}

A. 10
B. 0
C. 1
D. Undefined
Answer : C
7. What kind of expression is new Point(2,3)?
A. Primary Expression
B. Object Creation Expression
C. Invocation Expression
D. Constructor Calling Expression
Answer : B
8. In the following syntax, the data type within the square brackets must be ___________
book[datatype]=assignment_value;

A. An integer
B. A String
C. An object
D. Floating point
Answer : B
9. What is a block statement in JavaScript?
A. conditional block
B. block that contains a single statement
C. both conditional block and a single statement
D. block that combines multiple statements into a single compound statement
Answer : D
10. Consider the following code snippet.
for(var p in o)
console.log(o[p]);

The above code is equivalent to which code?

A.
for (var i = 0;i < a.length;i++)
console.log(a[i]);

B.
for (int i = 0;i < a.length;i++)
console.log(a[i]);

C.
for (var i = 0;i <= a.length;i++)
console.log(a[i]);

D.
for (var i = 1;i < a.length;i++)
console.log(a[i]);

Answer : A
11. What is the observation made in the following JavaScript code?
if (!a[i]) continue;

A. Skips the defined elements
B. Skips the existent elements
C. Skips the null elements
D. Skips the defined & existent elements
Answer : C
12. What will be the output of the following JavaScript code?

A. 125
B. 25
C. 5
D. Error
Answer : C
13. A function definition expression can be called as __________
A. Function prototype
B. Function literal
C. Function calling
D. Function declaration
Answer : B
14. The function stops its execution when it encounters?
A. continue statement
B. break statement
C. goto statement
D. return statement
Answer : D
15. The snippet that has to be used to check if a is not equal to null is _________
A. if(a!=null)
B. if (!a)
C. if(a!null)
D. if(a!==null)
Answer : D
16. The function definitions in JavaScript begins with _____________
A. Identifier and Parentheses
B. Return type and Identifier
C. Return type, Function keyword, Identifier and Parentheses
D. Identifier and Return type
Answer : C
17. The purpose of extensible attribute is to __________
A. make all of the own properties of that object non configurable
B. to configure and bring a writable property
C. lock down objects into a known state and prevent outside tampering
D. to include new properties into the object
Answer : C
18. What will be the output of the following Javascript code?
<script>
document.getElementById("demo").innerHTML = typeof "John"
</script>



A. integer
B. number
C. string
D. error
Answer : C
19. What will be the output of the following JavaScript code?
function output(object)
{
var place=object ? object.place : Italy;
return clean:+ place;
}
console.log(output({place:India}));

A. clean:India
B. clean:Italy
C. error
D. undefined
Answer : A
20. An expression that can legally appear on the left side of an assignment expression. is a well known explanation for variables, properties of objects, and elements of arrays. They are called ___________
A. Properties
B. Prototypes
C. Lvalue
D. Definition
Answer : C
21. What will happen if reverse() and join() methods are used simultaneously?
A. Reverses and stores in the same array
B. Reverses and concatenates the elements of the array
C. Reverses
D. Stores the elements of an array in normal order
Answer : A
22. Consider the following code snippet.
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);
}
}

What does the above code result?

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
Answer : A
23. JavaScript is ideal to ________
A. make computations in HTML simpler
B. minimize storage requirements on the web server
C. increase the download time for the client
D. increase the loading time of the website
Answer : B
24. Among the keywords below, which one is not a statement?
A. debugger
B. with
C. if
D. use strict
Answer : D
25. What will be the output of the following Javascript code?
int a=0;
for(a;a<5;a++);
console.log(a);

A. 0
B. error
C. 4
D. 5
Answer : D
26. Which of the following Attribute is used to include External JS code inside your HTML Document?
A. src
B. ext
C. script
D. link
Answer : A
27. One of the special feature of an interpreter in reference with the for loop is that ___________
A. Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property
B. The iterations can be infinite when an interpreter is used
C. The body of the loop is executed only once
D. the iteration is finite when an interpreter is used
Answer : A
28. What will be the output of the following JavaScript code?
const object1 = {
property1: 20
};
console.log(Object.is(object1));

A. 20
B. true
C. false
D. error
Answer : C
29. What will be the output of the following JavaScript code?
var obj=
{
length:20,
height:35,
}
if (breadth' in obj === false)
{
obj.breadth = 12;
}
console.log(obj.breadth);

A. 20
B. 12
C. undefined
D. error
Answer : B
30. The main purpose of a Live Wire in NetScape is to ________
A. Create linkage between client side and server side
B. Permit server side, JavaScript code, to connect to RDBMS
C. Support only non relational database
D. To interpret JavaScript code
Answer : B
31. The escape sequence stands for _________
A. Floating numbers
B. Representation of functions that returns a value
C. is not present in JavaScript
D. Form feed
Answer : D
32. What will be the output of the following JavaScript code?
const obj = {prop: 12};
Object.preventExtensions(obj);
console.log( Object.isExtensible(obj));

A. 12
B. false
C. true
D. error
Answer : B
33. The var and function are __________
A. Keywords
B. Declaration statements
C. Data types
D. Prototypes
Answer : B
34. What will be the output of the following Javascript code?
var a = 10;
do {
a += 1;
console.log(a);
} while (a < 5);

A. 11121314
B. 1112
C. 12345
D. 11
Answer : D
35. Which is a more efficient JavaScript code snippet?
Code 1 :
for(var num=10;num>=1;num--)
{
document.writeln(num);
}

Code 2 :
var num=10;
while(num>=1)
{
document.writeln(num);
num++;
}

A. Code 1
B. Code 2
C. Both Code 1 and Code 2
D. Cannot Compare
Answer : A
36. What is the prototype represents in the following JavaScript code snippet?
function f() {};

A. Function f
B. A custom constructor
C. Prototype of a function
D. Not valid
Answer : B
37. What is a block statement in JavaScript?
A. conditional block
B. block that contains a single statement
C. both conditional block and a single statement
D. block that combines multiple statements into a single compound statement
Answer : D
38. What will be the output of the following Javascript code?
<script>
var x = 10;
x *= 5;
document.getElementById("demo").innerHTML = x;
</script>



A. 5
B. 10
C. 50
D. Error
Answer : C
39. What will be the output of the following JavaScript code?
var grade='B';
var result;
switch(grade)
{
case 'A':
{
result+=10;
break;
}
case 'B':
{
result+= 9;
break;
}
case 'C':
{
result+= 8;
break;
}
default:
result+= 0;
}
document.write(result);

A. 10
B. 9
C. 8
D. 0
Answer : B
40. What will be the output of the following JavaScript code?
var grade='E';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);

A. 10
B. 0
C. 18
D. 17
Answer : B
41. Which of the following is not considered as an error in JavaScript?
A. Syntax error
B. Missing of semicolons
C. Division by zero
D. Missing of Bracket
Answer : C
42. A proper scripting language is a __________
A. High level programming language
B. Assembly level programming language
C. Machine level programming language
D. Low level programming language
Answer : A
43. The reduce and reduceRight methods follow a common operation called __________
A. filter and fold
B. inject and fold
C. finger and fold
D. fold
Answer : B
44. What will be the output of the following JavaScript code?

A. 7.25
B. -7.25
C. 7
D. -7
Answer : A
45. To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the ____________
A. isPrototypeOf() method
B. equals() method
C. === operator
D. ==opertor
Answer : A
46. What are the three important manipulations done in a for loop on a loop variable?
A. Updation, Incrementation, Initialization
B. Initialization,Testing, Updation
C. Testing, Updation, Testing
D. Initialization,Testing, Incrementation
Answer : B
47. JavaScript is a _______________ language.
A. Object-Oriented
B. High-level
C. Assembly-language
D. Object-Based
Answer : D
48. Consider the following code snippet :
var string2Num=parseInt(123xyz);

The result for the above code snippet would be :

A. 123
B. 123xyz
C. Exception
D. NaN
Answer : A
49. Consider the following code snippet :
var c = counter(), d = counter();
c.count()
d.count()
c.reset()
c.count()
d.count()

The state stored in d is :

A. 1
B. 0
C. Null
D. Undefined
Answer : A
50. What will be the output of the following JavaScript code?
var a1 = [,,,];
var a2 = new Array(3);
0 in a1
0 in a2

A. true false
B. false true
C. true true
D. false true
Answer : A

Sharing is caring