- The NaN property represents "Not-a-Number" value. This property indicates that a value is not a legal number.
- If you used string value instead of integer value in any of the statement, the statement will return NaN value.
- The NaN property is the same as the Number.NaN property.
Code:-
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script>
- /*NaN property representing Not-A-Number.
- If you are trying to convert string to integer, returns NaN.*/
- function cal_fun()
- {
- var str = "Testing";
- var num = parseInt(str);
- alert(num);
- }
- </script>
- </head>
- <body>
- <h2>NaN</h2>
- <button onclick="cal_fun();">Convert to Integer</button>
- </body>
- </html>
The NaN:- JavaScript
Reviewed by Network security
on
November 11, 2019
Rating:
No comments: