JavaScript NaN FunctionJavaScript's number feature enables you to represent numeric and floating numbers. JavaScript number has a particular value called NaN function, which means for Not-a-Number. NaN is an attribute of the global javascript object. The global object is used to show the window object in web browsers. There are used to NaN function in different ways.
SyntaxJavaScript provides us with the global function isNaN(). It returns true if its argument is NaN of the operation. The NaN function shows the true or false output of the given syntax. ExamplesThe following example shows multiple types of the number or NaN values using javascript. Example 1: The given an example shows NaN number in javascript using different display values. Here, we use positive, negative, and simple equation data. Output You can see the Boolean format data to check input value is NaN. Example 2: The given example shows NaN number in javascript using different display values. Here, we use number, string, equation, and date format input value. Output You can see the Boolean format data to check input value is NaN. Example 3: The given an example shows NaN numbers in javascript using different display values here. It uses positive, negative, and simple equation data. We can use a different method to check given number is Nan or not. Output You can see the Boolean format data to check input value is NaN. Example 4: The given an example shows NaN number in javascript using different display values. Here, we use other functions such as parseInt and parseFloat. Output You can see the Boolean format data to check input value is NaN. Example 5: The given example shows the NaN number in the javascript equation and other functions using different display values. Output You can see the Boolean format data to check input value is NaN. Why use the NaN FunctionJavaScript NaN function shows the result of a failed operation on numbers, including:
Supported BrowserThe following browser is used and supports the javascript NaN function. Almost all browsers and the latest version are supported by the NaN function.
ConclusionThe NaN() function is used to get or check given number is NaN or not using javascript. It is a global function to work with all types of data. Next TopicJavaScript onbeforeunload Event |