Home > Web Front-end > JS Tutorial > body text

Javascript Basic Tutorial Data Type (Number)_Basic Knowledge

WBOY
Release: 2016-05-16 16:19:45
Original
1105 people have browsed it

If you want to limit the value of a number in JavaScript, there is no need to limit whether it is an integer or a floating point number

Copy code The code is as follows:

var num1 = 80 ;
var num2 = 55.51;
var num3 = -34;
var num4 = 9e5;
Document.write(num1 " " num2 " " num3 " " num4);
//Run result 80 55.51 -34 900000
The

toExponential() function is to convert the numerical value into a scientific and technical display, for example:

Copy code The code is as follows:

document.write(num2.toExponential(9));//Output 5.551000000e 1

Go to the object properties and object methods of w3cschool values

Number object property

Property Description
constructor returns a reference to the Number function that created this object.
MAX_VALUE The largest number that can be represented.
MIN_VALUE The smallest number that can be represented.
NaN Not a numeric value.
NEGATIVE_INFINITY Negative infinity, this value is returned when overflow occurs.
POSITIVE_INFINITY Positive infinity, this value is returned when overflow occurs.
A prototype gives you the ability to add properties and methods to an object.

Number object method

Method Description
toString Converts a number to a string, using the specified base.
toLocaleString Converts a number to a string, using the local number format sequence.
toFixed converts a number into a string, and the result has the specified number of digits after the decimal point.
toExponential Converts the object's value to exponential notation.
toPrecision formats numbers to the specified length.
valueOf returns the base numeric value of a Number object.

The above is all about the values ​​​​in JavaScript data types. I hope you will like it.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!