ExamVeda
Login
Home
41
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?
Discuss
Answer & Solution
Answer: Option A
Solution:
The do/while loop is less commonly used when compared to the while loop. Here, it prints from the array in the given order.
42
What are the three important manipulations done in a for loop on a loop variable?
Discuss
Answer & Solution
Answer: Option B
Solution:
In a for loop, the initialization, the test, and the update are the three crucial manipulations of a loop variable.
43
Consider the following code snippet
function tail(o) 
{ 
    for (; o.next; o = o.next) ;
    return o;
}
Will the above code snippet work? If not, what will be the error?
Discuss
Answer & Solution
Answer: Option C
Solution:
The above code uses a for loop to traverse a linked list data structure and return the last object in the list. This will perfectly work.
44
One of the special feature of an interpreter in reference with the for loop is that
Discuss
Answer & Solution
Answer: Option A
Solution:
Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property (a string value) to it.
45
What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?
Discuss
Answer & Solution
Answer: Option C
Solution:
If the body of a for/in loop deletes a property that has not yet been enumerated, that property will not be enumerated. If the body of the loop defines new properties on the object, those properties will generally not be enumerated.
46
What will be the step of the interpreter in a jump statement when an exception is thrown?
Discuss
Answer & Solution
Answer: Option C
Solution:
When an exception is thrown in a jump statement, the interpreter jumps to the nearest enclosing exception handler, which may be in the same function or up the call stack in an invoking function.
47
Consider the following code snippet
while (a != 0)
{
   if (spam>a == 1) 
       continue;
   else 
       a++;
}
What will be the role of the continue keyword in the above code snippet?
Discuss
Answer & Solution
Answer: Option C
Solution:
Instead of exiting a loop like the break keyword, the continue keyword moves to the next iteration from the place encountered.
48
Consider the following code snippet

function f(o) 
{
     if (o === undefined) debugger;
}
What could be the task of the statement debugger?
Discuss
Answer & Solution
Answer: Option A
Solution:
The debugger statement normally does nothing. If, however, a debugger program is available and is running, then an implementation may (but is not required to) perform some kind of debugging action. In practice, this statement acts like a breakpoint: execution of JavaScript code stops and you can use the debugger to print variable’s values.
49
Among the keywords below, which one is not a statement?
Discuss
Answer & Solution
Answer: Option D
Solution:
use strict is a directive introduced in ECMAScript5. Directives are not statements because it does not include any language keywords. Also, it can appear only at the start of a script or at the start of a function body, before any real statemenst have appeared.
50
The unordered collection of properties, each of which has a name and a value is called
Discuss
Answer & Solution
Answer: Option B
Solution:
An object is an unordered collection of properties, each of which has a name and a value. Property names are strings, so we can say that objects map strings to values.