Home

NEET PG - JavaScript 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. Consider the following code snippet
function f(o)
{
if (o === undefined) debugger;
}

What could be the task of the statement debugger?

A. It does nothing but a simple breakpoint
B. It debugs the error in that statement and restarts the statements execution
C. It is used as a keyword that debugs the entire program at once
D. It is used to find error in the statement
Answer : A
2. 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
3. What will be the output of the following JavaScript code?
var pow=new Function(num1,num2,return Math.pow(num1,num2));
document.writeln(pow(2,3));

A. 2
B. 3
C. 8
D. error
Answer : C
4. What will be the output of the following Javascript code?
<script>
var x = 5;
var y = 2;
var z = x % y;
document.getElementById("demo").innerHTML = z;
</script>



A. 0
B. 1
C. 2
D. 5
Answer : B
5. What will be the output of the following JavaScript code?
var string1 = 123;
var intvalue = 123;
alert( string1 + intvalue );

A. 123246
B. 246
C. 123123
D. Exception
Answer : C
6. What will the following 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 not iterate
C. Yes, this will work
D. No, this will result in a runtime error with the message Cannot use Linked List
Answer : C
7. What will be the output of the following JavaScript code?
const obj1 = { property1: '10'};
const obj2 = Object.freeze(obj1);
obj2.property1 = '20';
console.log(obj2.property1);

A. 10
B. 20
C. Runtime error
D. Compilation error
Answer : A
8. The pop() method of the array does which of the following task?
A. decrements the total length by 1
B. increments the total length by 1
C. prints the first element but no effect on the length
D. updates the element
Answer : A
9. JavaScript is a _______________ language.
A. Object-Oriented
B. High-level
C. Assembly-language
D. Object-Based
Answer : D
10. What will be the possible output of the following JavaScript code?
var a = [1,2,3,4,5];
a.slice(0,3);

A. Returns [1,2,3]
B. Returns [4,5]
C. Returns [1,2,3,4]
D. Returns [1,2,3,4,5]
Answer : C
11. When does the function name become optional in JavaScript?
A. When the function is defined as a looping statement
B. When the function is defined as expressions
C. When the function is predefined
D. when the function is called
Answer : B
12. Among the following, which one is a ternary operator?
A. +
B. :
C. ^
D. ?:
Answer : D
13. 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
14. The function stops its execution when it encounters?
A. continue statement
B. break statement
C. goto statement
D. return statement
Answer : D
15. What will be the firstname and surname of the following JavaScript code?
var book = {
main title: JavaScript,
'sub-title': The Definitive Guide,
for: all audiences,
author: {
firstname: David,
surname: Flanagan
}
};

A. properties
B. property values
C. property names
D. objects
Answer : C
16. 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. The loop will not run
C. That property will not be enumerated
D. The property will be enumerated
Answer : C
17. 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
18. Consider the following code snippet :
var tensquared = (function(x) {return x*x;}(10));

Will the above code work ?

A. Yes, perfectly
B. Error
C. Exception will be thrown
D. Memory leak
Answer : A
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. 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
21. Assume that we have to convert false that is a non-string to string. The command that we use is (without invoking the new operator).
A. false.toString()
B. String(false)
C. String newvariable=false
D. Both false.toString() and String(false)
Answer : D
22. 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
23. What will be the output of the following Javascript code?
var add=new Function(num1,num2,return num1+num2);
document.writeln(add(2,5));

A. 2
B. 5
C. Error
D. 7
Answer : D
24. What will be the output of the following JavaScript code?
int a=1;
if(a!=null)
return 1;
else
return 0;

A. 1
B. 0
C. runtime error
D. compiler error
Answer : A
25. What will be the output of the following JavaScript code?
var values=[one,two,Three];
var ans=values.shift();
document.writeln(ans);

A. one
B. two
C. three
D. error
Answer : A
26. Which of the operator is used to test if a particular property exists or not?
A. in
B. exist
C. within
D. exists
Answer : A
27. 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
28. 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
29. What will be the equivalent code of the following JavaScript code?
o.m(x,y);

A. o.m(x) && o.m(y);
B. o[m](x,y);
C. o(m)[x,y];
D. o.m(x && y);
Answer : B
30. What will be the output of the following JavaScript code?
function output(option)
{
return (option ? yes : no);
}
bool ans=true;
console.log(output(ans));

A. Yes
B. No
C. Runtime error
D. Compilation error
Answer : A
31. The expression of calling (or executing) a function or method in JavaScript is called ________
A. Primary expression
B. Functional expression
C. Invocation expression
D. Property Access Expression
Answer : C
32. The generalised syntax for a real number representation is __________
A. [digits][.digits][(E|e)[(+|-)]digits]
B. [digits][+digits][(E|e)[(+|-)]digits]
C. [digits][(E|e)[(+|-)]digits]
D. [.digits][digits][(E|e)[(+|-)]digits]
Answer : A
33. For the below mentioned code snippet:
var o = new Object();

The equivalent statement is:

A. var o = Object();
B. var o;
C.
var o= new Object;
D. Object o=new Object();
Answer : C
34. 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
35. What will be the output of the following JavaScript code?
function equalto()
{
int num=10;
if(num===10)
return true;
else
return false;
}

A. true
B. false
C. runtime error
D. compilation error
Answer : A
36. What will be the output of the following JavaScript code?
var a=5 , b=1
var obj = { a : 10 }
with(obj)
{
alert(b)
}

A. 10
B. Error
C. 1
D. 5
Answer : C
37. Consider the following code snippet.
while (a != 0)
{
if (a == 1)
continue;
else
a++;
}

What will be the role of the continue keyword in the above code snippet?

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
Answer : C
38. Which keyword is used to define the function in javascript?
A. void
B. int
C. function
D. main
Answer : C
39. What will the following 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 not iterate
C. Yes, this will work
D. No, this will result in a runtime error with the message Cannot use Linked List
Answer : C
40. 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
41. 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
42. The web development environment (JavaScript) offers which standard construct for data validation of the input entered by the user.
A. Controlled loop constructs
B. Case checking constructs
C. Validation constructs
D. All of the mentioned
Answer : D
43. 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
44. What will be the output of the following JavaScript code?

A. 125
B. 25
C. 5
D. Error
Answer : C
45. 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
46. What will be the shift() output of the following JavaScript code?
var a = [];
a.unshift(1);
a.unshift(22);
a.shift();
a.unshift(3,[4,5]);
a.shift();
a.shift();
a.shift();

A. 1
B. [4,5]
C. [3,4,5]
D. Exception is thrown
Answer : A
47. 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
48. 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
49. 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
50. A function with no return value is called ___________
A. Procedures
B. Method
C. Static function
D. Dynamic function
Answer : A

Sharing is caring