FrontendDeveloper.in

JavaScript question detail

What is the output of below console statement with unary operator

Let's take console statement with unary operator as given below,

console.log(+"Hello"); // NaN

The output of the above console log statement returns NaN. Because the element is prefixed by the unary operator and the JavaScript interpreter will try to convert that element into a number type. Since the conversion fails, the value of the statement results in NaN value.

Back to all JavaScript questions
Get LinkedIn Premium at Rs 399