1+ +”2″+3 results 6 1+”2″+3 results “123” AS The unary + operator converts its operand to Number type. +”2″ is a way to cast the string “2” to the number 2 . The remain is a simple addition.
That’s why the answer is 73.
What would be the result of 3+2+”7″? Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57.
The $() function
The dollar function, $(), can be used as shorthand for the getElementById function. To refer to an element in the Document Object Model (DOM) of an HTML page, the usual function identifying an element is: document. … The $() function reduces the code to: $(“id_of_element”).
Whats the difference between += and =+?
+= is a compound assignment operator – it adds the RHS operand to the existing value of the LHS operand. =+ is just the assignment operator followed by the unary + operator.
3. 23. No, -1, 0, and 1 in a comparison function are used to tell the caller how the first value should be sorted in relation to the second one. -1 means the first goes before the second, 1 means it goes after, and 0 means they’re equivalent.
The increment operator adds 1 to the operand and the decrement operator subtracts 1 from the operand.
- Writing into an HTML element, using innerHTML .
- Writing into the HTML output using document.write() .
- Writing into an alert box, using window.alert() .
- Writing into the browser console, using console.log() .
|Que.||Consider the code snippet given below: var count = [1,,3]; What is the observation made?|
|b.||This results in an error|
|c.||This results in an exception|
|d.||None of the mentioned|
|Answer:The omitted value takes “undefined”|
NaN is a property of the global object. In other words, it is a variable in global scope. The initial value of NaN is Not-A-Number — the same as the value of Number. … There are five different types of operations that return NaN : Number cannot be parsed (e.g. parseInt(“blabla”) or Number(undefined) )