JavaScript Variables


JavaScript Variables

  1. Assume that we have to convert “false” that is a non-string to string. The command that we use is (without invoking the “new” operator)











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    The three approaches for converting to string are: value.toString(),”” + value and String(value). A non-string can be converted in two ways without using a new operator false.toString () and String(false).


  1. The statement p===q refers to _________











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    ”===” operator is known as strict comparison operator. A strict comparison (===) is only true if the operands are of the same type and the contents match.



  1. The snippet that has to be used to check if “a” is not equal to “null” is _________











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. The not-equal operator !== compares 0 to null and evaluates to either true or false.


  1. The escape sequence ‘\f’ stands for _________











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    \f is the JavaScript escape sequence that stands for Form feed (\u000C). It skips to the start of the next page. (Applies mostly to terminals where the output device is a printer rather than a VDU).



  1. Which of the following is not considered as an error in JavaScript?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Division by zero is not an error in JavaScript: it simply returns infinity or negative infinity. There is one exception, however: zero divided by zero does not have a well defined value, and the result of this operation is the special not-a-number value, printed as NaN.