Q. What is the difference between the two lines given below ?

Code:
!!(obj1 && obj2);
(obj1 && obj2);
  • (A) Both the lines result in a boolean value “True”
  • (B) Both the lines checks just for the existence of the object alone
  • (C) Both the lines result in a boolean value “False”
  • (D) The first line results in a real boolean value whereas the second line merely checks for the existence of the objects
πŸ’¬ Discuss
βœ… Correct Answer: (D) The first line results in a real boolean value whereas the second line merely checks for the existence of the objects

Q. Consider the following code snippet : The state stored in d is :

Code:
var c = counter(), d = counter(); 
c.count()
d.count() 
c.reset() 
c.count() 
d.count()
  • (A) 1
  • (B) 0
  • (C) Null
  • (D) Undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1

Q. Consider the following code snippet:
What does the last statement return ?

Code:
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]()
  • (A) 9
  • (B) 0
  • (C) 10
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (C) 10

Q. What kind of scoping does JavaScript use?

  • (A) Literal
  • (B) Segmental
  • (C) Lexical
  • (D) Sequential
πŸ’¬ Discuss
βœ… Correct Answer: (C) Lexical

Q. What must be done in order to implement Lexical Scoping?

  • (A) Dereference the current scope chain
  • (B) Get the object
  • (C) Reference the current scope chain
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (C) Reference the current scope chain

Q. The escape sequence ‘f’ stands for

  • (A) Floating numbers
  • (B) Representation of functions that returns a value
  • (C) f is not present in JavaScript
  • (D) Form feed
πŸ’¬ Discuss
βœ… Correct Answer: (D) Form feed

Q. Which one of the following symbol is used for creating comments in the javascript

  • (A) \\
  • (B) //
  • (C) \* *\
  • (D) \* */
πŸ’¬ Discuss
βœ… Correct Answer: (B) //

Q. Which of the following is the correct output for the following JavaScript code:

Code:
    functiondisplayArray(x)  
    {  
    varlen=x.length,i=0;  
    if(len==0)  
    console.log("Empty Array");  
    else  
    {  
    do  
    {  
                 console.log(x[i]);  
    } while (++i<len);  
    }  
    }  
  • (A) Prints the numbers in the array in specific order
  • (B) Prints the numbers in the array in the reverse order
  • (C) Prints "Empty Array"
  • (D) Prints 0 to the length of the array
πŸ’¬ Discuss
βœ… Correct Answer: (A) Prints the numbers in the array in specific order

Q. Which one of the given code will be equivalent for the following JavaScript code:

Code:
for(var p in o)  
console.log(o[p]);  
  • (A) for (var i = 1;i<a.length;i++) console.log(a[i]);
  • (B) for (var i = 0;i<a.length;i++) console.log(a[i]);
  • (C) for (int i = 0;i<a.length;i++) console.log(a[i]);
  • (D) for (var i = 0;i<= a.length;i++) console.log(a[i]);
πŸ’¬ Discuss
βœ… Correct Answer: (A) for (var i = 1;i<a.length;i++) console.log(a[i]);

Q. What are the three important manipulations for a loop on a loop variable?

  • (A) Updation, Incrementation, Initialization
  • (B) Initialization, Testing, Incrementation
  • (C) Testing, Updation, Testing
  • (D) Initialization, Testing, Updation
πŸ’¬ Discuss
βœ… Correct Answer: (D) Initialization, Testing, Updation