JavaScript While Loop


JavaScript While Loop

  1. Among the keywords below, which one is not a statement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    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 statement has appeared.


  1. Consider the following code snippet
    function fun(f) 
    {
    if (f === undefined) debugger;
    }

    What could be the task of the statement debugger?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    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.



  1. Consider the following code snippet.
    while (n != 0)
    {
    if (n == 1)
    continue;
    else
    n++;
    }

    What will be the role of the continue keyword in the above code snippet?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Instead of exiting a loop like the break keyword, the continue keyword moves to the next iteration from the place encountered. While the break statement breaks out of the loop.


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    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.



  1. What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    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.