This article describes the second of nine data types in javascript-Number, which is very simple to use. We recommend it to our friends here. In javascript, you do not need to specify whether it is an integer or a floating-point number.
The Code is as follows:
Var num1 = 80;
Var num2 = 55.51;
Var num3 =-34;
Var num4 = 9e5;
Document. write (num1 + "" + num2 + "" + num3 + "" + num4 );
// The running result is 80 55.51-34 900000.
The toExponential () function is used to convert a value into a scientific and technical display. For example:
The Code is as follows:
Document. write (num2.toExponential (9); // output 5.55000000e + 1
Convert the object attributes and object methods of the w3cschool Value
Number Object Attributes
Attribute description
Constructor returns a reference to the Number function that creates this object.
MAX_VALUE indicates the maximum number.
MIN_VALUE represents the smallest number.
NaN is a non-numeric value.
NEGATIVE_INFINITY is negative infinity. This value is returned when overflow occurs.
POSITIVE_INFINITY is positive infinity. This value is returned when overflow occurs.
Prototype enables you to add attributes and methods to an object.
Number object Method
Method description
ToString converts a number to a string and uses the specified base number.
ToLocaleString converts a number to a string in the local numeric format order.
ToFixed converts a number to a string, and the result has a specified number of digits after the decimal point.
ToExponential converts the object value into an exponential notation.
ToPrecision format the number to the specified length.
ValueOf returns the basic numeric value of A Number object.
The above is all about the values in the javascript data type. I hope you will like it.