The Number data type in JavaScript is used to represent numeric values and can be created through literals, Number() function or parseInt(). The following properties and methods are available: .valueOf(), .toFixed(n), .toPrecision(n), .toLocaleString(), .isNaN(), and .isFinite(). The Number type supports addition, subtraction, multiplication, division, and modulo operations. NaN represents a non-numeric value, while Infinity represents infinity.
Number in JavaScript
Number data type
Number Data types are used to represent numeric values. It is a built-in data type used to handle integers and decimals.
Create Number
You can create a Number object in the following ways:
const num = 123;
const num = Number("123");
const int = parseInt("123"); // Returns the integer 123
Number Properties and Methods
Number object has the following useful properties and Method:
Number operations
Number type supports the following operations:
NaN and Infinity
NaN (not a number) represents a value that is not a valid number. Infinity means infinity. These values can be generated by arithmetic operations, for example:
// NaN
// Infinity
The above is the detailed content of What does number mean in js. For more information, please follow other related articles on the PHP Chinese website!