JavaScript Statements


JavaScript Statements

  1. A conditional expression is also called a _______________.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    A conditional expression can evaluate to either True or False based on the evaluation of the condition. If the condition is true then the value following the operator is taken that’s why it is called immediate if.


  1. What is block statement in JavaScript?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    A block statement groups zero or more statements. In languages other than JavaScript, it is known as a compound statement. A statement block is a block that combines more than one statements into a single compound statement for ease.



  1. What is block statement in JavaScript?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    A block statement groups zero or more statements. In languages other than JavaScript, it is known as a compound statement. A statement block is a block that combines more than one statements into a single compound statement for ease.


  1. Which is a more efficient code snippet?
    Code 1 :
    for(var n=10;n>=1;n--)
    {
    document.writeln(n);
    }


    Code 2 :

    var n=10;
    while(n>=1)
    {
    document.writeln(n);
    n++;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Code 1 would be more efficient. Infact second code will go into runtime error as the value of num will never reach less than or equal to one.



  1. What would be the most appropriate output for the following code snippet?
    var p=15 , q=10
    var object = { p : 20 }
    with(object)
    {
    alert(q)
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Firstly the interpreter checks obj for property b.But it doesn’t find any property b so it takes the value from outside the object within the code snippet.