JavaScript Number

JavaScript Number object is encapsulated in an object allows you handle digital value. Number Object () constructor is created by Number.

Number The main target for:

  • If the argument can not be converted to a number, the return  NaN.
  • In the context of non-structural (eg: no  new operator), Number that can be used to perform the type of conversion.

Common attributes

Property name Explanation
Number.EPSILON Two may represent a minimum interval between (representable) Number
Number.MAX_SAFE_INTEGER Maximum security integer in JavaScript (253--1).
Number.MAX_VALUE The maximum number of positive energy represented. The smallest negative number is -MAX_VALUE.
Number.MIN_SAFE_INTEGER JavaScript security smallest integer (- (253 - 1)).
Number.MIN_VALUE The smallest positive number that is a positive number that can be represented (in fact, does not become 0) is closest to zero. The biggest negative is -MIN_VALUE.
Number.NaN Special "not a number" value.
Number.NEGATIVE_INFINITY Special negative infinite value, that value is returned in case of overflow.
Number.POSITIVE_INFINITY Special positive infinite value, change the value returned in case of overflow.
Number.prototype Number of additional objects allowed on property.

  

A common method

method Explanation
Number.isNaN() Determine whether the value of the transfer is NaN.
Number.isFinite() Determining whether the passed value type is limited and the number itself.
Number.isInteger() Transmission type determination value is "number", and is an integer.
Number.isSafeInteger() Value determines whether the security passed integer (- (253 - 1) to 253 - between 1).
Number.toInteger() Calculated value passed and convert it to an integer (or infinite)
Number.parseFloat() And global objects parseFloat () the same.
Number.parseInt() And global objects parseInt () the same.
toFixed() A fixed-point number notation format.

 

 

 

Examples

 1 <!DOCTYPE html>
 2 <html lang="zh">
 3 <head>
 4 <meta charset="UTF-8">
 5 <title>Number对象</title>
 6 </head>
 7 <body>
 8 <script>
 9   var big = Number.MAX_VALUE;//调用number对象的MAX_VALUE最大值
10   document.write(big);
11   
12 is    document.write ( ' <br> ' );
 13 is    
14    var n- =  . 11 ;
 15    var binary_value = n.toString ( 2 ); // toString () to convert the digital strings, the specified base. 
16    document.write (binary_value);
 . 17  </ Script > 
18 is  </ body > 
. 19  </ HTML >

Web site: https: //developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number

You can also search box, the search site from the browser: developer.mozilla.org number

Guess you like

Origin www.cnblogs.com/hzyhx/p/10984070.html