数字方法: toInt和Math
返回一个指定进制的数字。 必须作用在字符串和数字上。
语法:
myNumber.toInt([base]);
参数:
- base - (number, 可选的: 默认为 10) 应用的进制。
返回值:
- (number) 指定进制的数字。
举例:
(111).toInt(); // 返回 111
(111.1).toInt(); // 返回 111
(111).toInt(2); // 返回 7
数学方法 (Math)
返是一些Math对象可用的方法在这里也可以使用。
- abs
- acos
- asin
- atan2
- ceil
- cos
- exp
- floor
- log
- max
- min
- pow
- sin
- sqrt
- tan
举例:
(-1).abs(); // 返回 1
(3).pow(4); // 返回 81