MCQOPTIONS
Saved Bookmarks
This section includes 14 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 :function constfunctions() { var functions = []; for(var k = 0; k < 10; k++) functions [k] = function() { return k; }; return functions ;}var functions = constfunctions();functions [5]()What does the last statement return ? |
| A. | 10 |
| B. | 9 |
| C. | 0 |
| D. | All of above |
| E. | None of these |
| Answer» B. 9 | |
| 2. |
Consider the following code snippet :var p = counter(), q = counter(); p.count()q.count() p.reset() p.count() q.count()The state stored in q is : |
| A. | Undefined |
| B. | Null |
| C. | 0 |
| D. | 1 |
| E. | None of these |
| Answer» E. None of these | |
| 3. |
What is the difference between the two lines given below ?!!(object1 && object2);(object1 && object2); |
| A. | Both the lines checks just for the existence of the object alone |
| B. | The first line results in a real boolean value whereas the second line merely checks for the existence of the objects |
| C. | Both the lines result in a boolean value False |
| D. | Both the lines result in a boolean value True |
| E. | None of these |
| Answer» C. Both the lines result in a boolean value False | |
| 4. |
For the below mentioned code snippet:var obj = new Object();The equivalent statement is: |
| A. | Object obj=new Object(); |
| B. | var obj= new Object; |
| C. | var obj; |
| D. | var obj = Object(); |
| E. | None of these |
| Answer» C. var obj; | |
| 5. |
Consider the following code snippet :var string2Number=parseInt("456pqr"); |
| A. | 456pqr |
| B. | Exception |
| C. | NaN |
| D. | 456 |
| E. | None of these |
| Answer» E. None of these | |
| 6. |
Consider the following code snippet :var tensquared = (function(n) {return n*n;}(100));Will the above code work ? |
| A. | Memory leak |
| B. | Exception will be thrown |
| C. | Error |
| D. | Yes |
| E. | None of these |
| Answer» E. None of these | |
| 7. |
Consider the following code snippet :var Total=eval("5*5+10"); |
| A. | 35 as an integer value |
| B. | 35 as a string |
| C. | Exception is thrown |
| D. | 5*5+10 |
| E. | None of these |
| Answer» B. 35 as a string | |
| 8. |
Consider the following code snippetopt.fun(p,q);Which is an equivalent code for the above code snippet? |
| A. | opt.fun(p && q); |
| B. | opt(fun)["p","q"]; |
| C. | opt.fun(p) && opt.fun(q); |
| D. | opt["fun"](p,q); |
| E. | None of these |
| Answer» E. None of these | |
| 9. |
Consider the following code snippetfunction output(n) { for(var v in n) console.log(v + ": " + n[v] + " n");}What will the above code snippet result ? |
| A. | prints only one property |
| B. | Prints the contents of each property of n |
| C. | prints the address of elements |
| D. | Returns undefined |
| E. | None of these |
| Answer» E. None of these | |
| 10. |
Consider the following code snippetfunction hypotenuse(p, q) { function square(n) { return n*n; } return Math.sqrt(square(p) + square(q));}What does the above code result? |
| A. | Square of sum of p and q |
| B. | Sum of p and q square |
| C. | Sum of square of p and q |
| D. | All of above |
| E. | None of these |
| Answer» D. All of above | |
| 11. |
Which is an equivalent code to invoke a function fun of class opt that expects two arguments p and q? |
| A. | opt.fun(p,q); |
| B. | fun(p,q); |
| C. | opt.fun(p) && opt.fun(q); |
| D. | opt(p,q); |
| E. | None of these |
| Answer» B. fun(p,q); | |
| 12. |
What is the difference between the two lines given below ? |
| A. | Both the lines checks just for the existence of the object alone |
| B. | The first line results in a real boolean value whereas the second line merely checks for the existence of the objects |
| C. | Both the lines result in a boolean value False |
| D. | Both the lines result in a boolean value True |
| E. | None of these |
| Answer» C. Both the lines result in a boolean value False | |
| 13. |
Consider the following code snippet : |
| A. | Undefined |
| B. | Null |
| C. | 0 |
| D. | 1 |
| E. | None of these |
| Answer» E. None of these | |
| 14. |
For the below mentioned code snippet: |
| A. | Object obj=new Object(); |
| B. | var obj= new Object; |
| C. | var obj; |
| D. | var obj = Object(); |
| E. | None of these |
| Answer» C. var obj; | |