Q. Consider the following code snippet.
What could be the task of the statement debugger?

Code:
function fun(f) 
{
     if (f === undefined) debugger;
}
  • (A) It is used to find error in the statement
  • (B) It is used as a keyword that debugs the entire program at once
  • (C) It debugs the error in that statement and restarts the statement’s execution
  • (D) It does nothing but a simple breakpoint
πŸ’¬ Discuss
βœ… Correct Answer: (D) It does nothing but a simple breakpoint

Q. Consider the following code snippet.
What will be the role of the continue keyword in the above code snippet?

Code:
while (n != 0)
{
   if (n == 1) 
       continue;
   else 
       n++;
}
  • (A) The continue keyword breaks out of the loop
  • (B) The continue keyword restarts the loop
  • (C) The continue keyword skips the next iteration
  • (D) The continue keyword skips the rest of the statements in that iteration
πŸ’¬ Discuss
βœ… Correct Answer: (D) The continue keyword skips the rest of the statements in that iteration

Q. What will be the step of the interpreter in a jump statement when an exception is thrown?

  • (A) The interpreter throws an error
  • (B) The interpreter jumps to the nearest enclosing exception handler
  • (C) The interpreter stops its work
  • (D) The interpreter throws another exception
πŸ’¬ Discuss
βœ… Correct Answer: (B) The interpreter jumps to the nearest enclosing exception handler

Q. 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 enumerated
  • (B) The loop will not run
  • (C) The property will be stored in a cache
  • (D) That property will not be enumerated
πŸ’¬ Discuss
βœ… Correct Answer: (A) The property will be enumerated

Q. One of the special feature of an interpreter in reference with the for loop is that

  • (A) the iteration is finite when an interpreter is used
  • (B) The body of the loop is executed only once
  • (C) Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property
  • (D) The iterations can be infinite when an interpreter is used
πŸ’¬ Discuss
βœ… Correct Answer: (C) Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property

Q. What will the following code snippet work? If not, what will be the error?

Code:
function test(p) 
{ 
    for (; p.next; p = p.next) ;
    return p;
}
  • (A) No, this will not iterate
  • (B) No, this will result in a runtime error with the message “Cannot use Linked List”
  • (C) No, this will throw an exception as only numerics can be used in a for loop
  • (D) Yes, this will work
πŸ’¬ Discuss
βœ… Correct Answer: (D) Yes, this will work

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

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

Q. Consider the following code snippet.
What does this code result?

Code:
function printArr(n) 
{
     var len = n.length, p = 2;
     if (len == 2)
        console.log("Nothing is in Array");
     else 
     {
         do 
         {
             console.log(n[p]);
         } while (++p < len);
     }
}
  • (A) Prints the numbers in the array in the reverse order
  • (B) Prints the numbers in the array in order
  • (C) Prints “Nothing is in Array”
  • (D) Prints 2 to the length of the array
πŸ’¬ Discuss
βœ… Correct Answer: (B) Prints the numbers in the array in order

Q. Javascript is an _______ language?

  • (A) Object-Oriented
  • (B) Object-Based
  • (C) Assembly-language
  • (D) High-level
πŸ’¬ Discuss
βœ… Correct Answer: (B) Object-Based

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

Code:
varx=5,y=1  
var obj ={ x:10}  
with(obj)  
{  
      alert(y)  
}  
  • (A) 1
  • (B) Error
  • (C) 10
  • (D) 5
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1
Explanation: The output of the above snippet code will be one because, first of all, the interpreter will search "obj" for the property (y). But it fails to find "obj" for property "y," so it chooses a value from outside the object, which is available within the given code.