栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

javascript中Number的方法小结

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

javascript中Number的方法小结

一、构造函数

  Number(value)

  new Number(value)

二、Number属性

  1、Number.MAX_VALUE  返回能表示的最大数字。

  2、Number.MIN_VALUE   能表示的最小数字。

  3、Number.NAN      非数字值。

  4、Number.NEGATIVE_INFINITY  负无穷,当溢出时返回。

  5、Number.POSITIVE_INFINITY   正无穷,当溢出时返回。

三、Number方法

  1、toString()  使用指定进制,将一个数字转换为字符串。

  2、toLocaleString()  将一个数字转换为本地数字格式的字符串。

  3、toFixed()    将一个数字转换为包含指定小数位数的字符串。

  4、toExponential()  讲一个数字转换为字符串,使用指定数目的有效数字。

  5、valueOf()    返回一个Number对象的原始值。

  6、toExponential()  用指数计数法格式化一个数字

 document.write(Number.MIN_VALUE + "
"); //5e-324 document.write(Number.MAX_VALUE + "
"); //1.7976931348623157e+308 document.write(Number.NaN + "
"); //NaN document.write(Number.NEGATIVE_INFINITY + "
"); //-Infinity document.write(Number.POSITIVE_INFINITY + "
"); //Infinity var num = Number(5.123); //5.123 document.write(num.toString() + "
"); //5.123 document.write(num.toFixed(2) + "
"); //5.123 document.write(num.toPrecision(2) + "
"); //5.123 document.write(num.valueOf() + "
"); //5.123 document.write(num.toExponential(1)); //5.1e+0

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/92661.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号