

MCQOPTIONS
Saved Bookmarks
This section includes 52 Mcqs, each offering curated multiple-choice questions to sharpen your Javascript knowledge and support exam preparation. Choose a topic below to get started.
1. |
Consider the following code snippet :var scope = "global scope";function checkscope() {var scope = "local scope";function f(){return scope;}return f;What is the function of the above code snippet? |
A. | eturns value null |
B. | eturns exception |
C. | eturns the value in scope |
D. | one of the mentioned |
Answer» D. one of the mentioned | |
2. |
Consider the following code snippetfunction hypotenuse(a, b){function square(x){return x*x;}return Math.sqrt(square(a) + square(b));}What does the above code result? |
A. | um of square of a and b |
B. | quare of sum of a and b |
C. | um of a and b square |
D. | one of the mentioned |
Answer» B. quare of sum of a and b | |
3. |
Consider the following code snippetfunction printprops(o){for(var p in o)console.log(p + ": " + o[p] + "n");}What will the above code snippet result ? |
A. | rints the contents of each property of o |
B. | eturns undefined |
C. | ll of the mentioned |
D. | one of the mentioned |
Answer» C. ll of the mentioned | |
4. |
Consider the following code snippetvar a1 = [,,,];var a2 = new Array(3);">0 in a10 in a2The result would be |
A. | rue false |
B. | alse true |
C. | rue true |
D. | alse true |
Answer» B. alse true | |
5. |
Which of the algorithmic languages is lexical scoping standardized in?%! |
A. | Ada |
B. | Pascal |
C. | Modula2 |
D. | All of the mentioned |
Answer» E. | |
6. |
What is the purpose of the dynamic scoping?%! |
A. | Variables can be declared outside the scope |
B. | Variables must be declared outside the scope |
C. | Variables cannot be declared outside the scope |
D. | None of the mentioned |
Answer» B. Variables must be declared outside the scope | |
7. |
What is the opposite approach to the lexical scoping?%! |
A. | Literal scoping |
B. | Static scoping |
C. | Dynamic scoping |
D. | Generic scoping |
Answer» D. Generic scoping | |
8. |
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. | All of the mentioned |
Answer» B. Reverses and concatenates the elements of the array | |
9. |
The method or operator used to identify the array is%! |
A. | isarrayType() |
B. | == |
C. | === |
D. | typeof |
Answer» E. | |
10. |
What will happen if a return statement does not have an associated expression?%! |
A. | It returns the value 0 |
B. | It will throw an exception |
C. | It returns the undefined value |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
11. |
Consider the following code snippet :var grand_Total=eval("10*10+5");The output for the above statement would be :%! |
A. | 10*10+5 |
B. | 105 as a string |
C. | 105 as an integer value |
D. | Exception is thrown |
Answer» D. Exception is thrown | |
12. |
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» D. Object o=new Object(); | |
13. |
What must be done in order to implement Lexical Scoping?%! |
A. | Get the object |
B. | Dereference the current scope chain |
C. | Reference the current scope chain |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
14. |
What is the fundamental rule of lexical scoping?%! |
A. | Functions are declared in the scope |
B. | Functions are executed using scope chain |
C. | All of the mentioned |
D. | None of the mentioned |
Answer» C. All of the mentioned | |
15. |
*$_The method or operator used to identify the array is? |
A. | isarrayType() |
B. | == |
C. | === |
D. | typeof |
Answer» E. | |
16. |
*$_What will happen if a return statement does not have an associated expression?? |
A. | It returns the value 0 |
B. | It will throw an exception |
C. | It returns the undefined value |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
17. |
*$_What must be done in order to implement Lexical Scoping?? |
A. | Get the object |
B. | Dereference the current scope chain |
C. | Reference the current scope chain |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
18. |
*$_What is the fundamental rule of lexical scoping?? |
A. | Functions are declared in the scope |
B. | Functions are executed using scope chain |
C. | All of the mentioned |
D. | None of the mentioned |
Answer» C. All of the mentioned | |
19. |
*$_Consider the following code snippet :var grand_Total=eval("10*10+5");The output for the above statement would be :? |
A. | 10*10+5 |
B. | 105 as a string |
C. | 105 as an integer value |
D. | Exception is thrown |
Answer» D. Exception is thrown | |
20. |
*$_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» D. Object o=new Object(); | |
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. | All of the mentioned |
Answer» B. Reverses and concatenates the elements of the array | |
22. |
_ 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» C. finger and fold | |
23. |
_ 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» E. | |
24. |
_ What kind of scoping does JavaScript use?$? |
A. | Literal |
B. | Lexical |
C. | Segmental |
D. | Sequential |
Answer» C. Segmental | |
25. |
_ Consider the following code snippet :var scope = "global scope";function checkscope() {var scope = "local scope"; function f() { return scope; }return f;What is the function of the above code snippet?$? |
A. | Returns value null |
B. | Returns exception |
C. | Returns the value in scope |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
26. |
_ Which is an equivalent code to invoke a function m of class o that expects two arguments x and y?$? |
A. | o(x,y); |
B. | o.m(x) && o.m(y); |
C. | m(x,y); |
D. | o.m(x,y); |
Answer» E. | |
27. |
_ If you have a function f and an object o, you can define a method named m of o with$? |
A. | o.m=m.f; |
B. | o.m=f; |
C. | o=f.m; |
D. | o=f; |
Answer» B. o.m=f; | |
28. |
_ Consider the following code snippet :if (!a[i]) continue ;What is the observation made ?$? |
A. | Skips the undefined elements |
B. | Skips the non existent elements |
C. | Skips the null elements |
D. | All of the mentioned |
Answer» E. | |
29. |
_The primary purpose of the array map() function is that it$? |
A. | maps the elements of another array into itself |
B. | passes each element of the array and returns the necessary mapped elements |
C. | passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
30. |
_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. | All of the mentioned |
Answer» C. When the function is predefined | |
31. |
_Consider the following code snippet :var c = counter(), d = counter(); function constfuncs() { var funcs = []; for(var i = 0; i < 10; i++) funcs[i] = function() { return i; }; return funcs;}var funcs = constfuncs();funcs[5]()What does the last statement return ?$? |
A. | 9 |
B. | 0 |
C. | 10 |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
32. |
_Which of the following uses a lot of CPU cycles?$? |
A. | GUI |
B. | Statically generated graphics |
C. | Dynamically generated graphics |
D. | All of the mentioned |
Answer» D. All of the mentioned | |
33. |
_Which of the following is the correct code for invoking a function without this keyword at all, and also too determine whether the strict mode is in effect?$? |
A. | var strict = (function { return this; }); |
B. | mode strict = (function() { return !this; }()); |
C. | var strict = (function() { return !this; }()); |
D. | mode strict = (function { }); |
Answer» D. mode strict = (function { }); | |
34. |
_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» C. Exception | |
35. |
_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. | None of the mentioned |
Answer» B. increments the total length by 1 | |
36. |
Consider the following code snippet :var a = []; a.unshift(1); a.unshift(22);a.shift(); a.unshift(3,[4,5]); a.shift(); a.shift();a.shift();The final output for the shift() is$? |
A. | 1 |
B. | [4,5] |
C. | [3,4,5] |
D. | Exception is thrown |
Answer» B. [4,5] | |
37. |
Consider the following code snippetfunction printprops(o) { for(var p in o) console.log(p + ": " + o[p] + "n");}What will the above code snippet result ?$? |
A. | Prints the contents of each property of o |
B. | Returns undefined |
C. | All of the mentioned |
D. | None of the mentioned |
Answer» C. All of the mentioned | |
38. |
Consider the following code snippetfunction hypotenuse(a, b) { function square(x) { return x*x; } return Math.sqrt(square(a) + square(b));}What does the above code result?$? |
A. | Sum of square of a and b |
B. | Square of sum of a and b |
C. | Sum of a and b square |
D. | None of the mentioned |
Answer» B. Square of sum of a and b | |
39. |
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» B. Error | |
40. |
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» B. 0 | |
41. |
Which of the following are examples of closures?$? |
A. | Objects |
B. | Variables |
C. | Functions |
D. | All of the mentioned |
Answer» E. | |
42. |
Consider the following code snippet :var a = []; a.unshift(1); a.unshift(22);a.shift(); a.unshift(3,[4,5]); a.shift(); a.shift();a.shift();The final output for the shift() is? |
A. | 1 |
B. | [4,5] |
C. | [3,4,5] |
D. | Exception is thrown |
Answer» B. [4,5] | |
43. |
Consider the following code snippetfunction printprops(o) { for(var p in o) console.log(p + ": " + o[p] + "n");}What will the above code snippet result ?? |
A. | Prints the contents of each property of o |
B. | Returns undefined |
C. | All of the mentioned |
D. | None of the mentioned |
Answer» C. All of the mentioned | |
44. |
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» B. 0 | |
45. |
Which of the following are examples of closures?? |
A. | Objects |
B. | Variables |
C. | Functions |
D. | All of the mentioned |
Answer» E. | |
46. |
Consider the following code snippetfunction hypotenuse(a, b) { function square(x) { return x*x; } return Math.sqrt(square(a) + square(b));}What does the above code result?? |
A. | Sum of square of a and b |
B. | Square of sum of a and b |
C. | Sum of a and b square |
D. | None of the mentioned |
Answer» B. Square of sum of a and b | |
47. |
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» B. Error | |
48. |
Consider the following code snippetvar a1 = [,,,]; var a2 = new Array(3); ">0 in a1 0 in a2The result would be |
A. | true false |
B. | false true |
C. | true true |
D. | false true |
Answer» B. false true | |
49. |
Consider the following code snippet :var a = [1,2,3,4,5];a.slice(0,3);What is the possible output for the above code snippet ? |
A. | Returns [1,2,3] |
B. | Returns [4,5] |
C. | Returns [1,2,3,4] |
D. | Returns [1,2,3,4,5] |
Answer» B. Returns [4,5] | |
50. |
What is the difference between the two lines given below ?!!(obj1 && obj2);(obj1 && obj2); |
A. | Both the lines result in a boolean value “True” |
B. | Both the lines result in a boolean value “False” |
C. | Both the lines checks just for the existence of the object alone |
D. | The first line results in a real boolean value whereas the second line merely checks for the existence of the objects |
Answer» E. | |