Home / CSE / Javascript - CS :: Basic and Variables

CSE :: Javascript - CS

  1. The output for the following code snippet would most appropriately be

    var a=5 , b=1

    var obj = { a : 10 }

    with(obj)

    {

    alert(b)

    }

  2. A.

     10

    B.

     Error

    C.

     1

    D.

     5


  3. The output for the following code snippet would most appropriately be

    var a=5 , b=1

    var obj = { a : 10 }

    with(obj)

    {

    alert(b)

    }

  4. A.

     10

    B.

     Error

    C.

     1

    D.

     5


  5. A conditional expression is also called a

  6. A.

     Alternate to if-else

    B.

     Immediate if

    C.

     If-then-else statement

    D.

     None of the mentioned


  7. Which is a more efficient code snippet ?
    Code 1 :

    for(var num=10;num>=1;num--)

    {

    document.writeln(num);

    }


    Code 2 :

    var num=10;

    while(num>=1)

    {

    document.writeln(num);

    num++;

    }

  8. A.

     Code 1

    B.

     Code 2

    C.

     Both Code 1 and Code 2

    D.

     Cannot Compare


  9. A statement block is a

  10. A.

     conditional block

    B.

     block that contains a single statement

    C.

     Both conditional block and single statement

    D.

     block that combines multiple statements into a single compound statement


  11. When an empty statement is encountered, a JavaScript interpreter

  12. A.

     Ignores the statement

    B.

     Prompts to complete the statement

    C.

     Throws an error

    D.

     Throws an exception


  13. The “var” and “function” are

  14. A.

     Keywords

    B.

     Declaration statements

    C.

     Datatypes

    D.

     Prototypes


  15. Consider the following statements

    switch(expression)

    {

    statements

    }

    In the above switch syntax, the expression is compared with the case labels using which of the following operator(s) ?

  16. A.

     ==

    B.

     equals

    C.

     equal

    D.

     ===


  17. Consider the following statements

    var count = 0;

    while (count < 10)

    {

    console.log(count);

    count++;

    }

    In the above code snippet, what happens?

  18. A.

     The values of count is logged or stored in a particular location or storage

    B.

     The value of count from 0 to 9 is displayed in the console

    C.

     An error is displayed

    D.

     An exception is thrown


  19. The enumeration order becomes implementation dependent and non-interoperable if :

  20. A.

     If the object inherits enumerable properties

    B.

     The object does not have the properties present in the integer array indices

    C.

     The delete keyword is never used

    D.

     Object.defineProperty() is not used