当前位置: 首页 > news >正文

西安企业网站设计机构网络产品及其推广方法

西安企业网站设计机构,网络产品及其推广方法,丹东seo排名公司,湘潭企业网站建设 磐石网络1. 二进制和八进制的表示法 二进制和八进制的前缀分别为0b(或0B)和0o(或0O)表示 在ES5的严格模式下,八进制不再允许使用前缀0表示 如果要将0b和0x前缀的字符串数值转为十进制,要使用Number方法 Number(0b111); // 7 Number(0o10); // 82. Number.isF…

1. 二进制和八进制的表示法

二进制和八进制的前缀分别为0b(或0B)和0o(或0O)表示

在ES5的严格模式下,八进制不再允许使用前缀0表示

如果要将0b0x前缀的字符串数值转为十进制,要使用Number方法

Number('0b111'); // 7
Number('0o10'); // 8

2. Number.isFinite()、Number.isNaN()

Number.isFinite()用来检测一个数值是否是有限的(finite)。


Number.isFinite(15); // true
Number.isFinite(NaN); // false
Number.isFinite(Infinity); // false
Number.isFinite('foo'); // false
Number.isFinite(true); // false

Number.isNaN() 用来检测一个值是否为NaN


Number.isNaN(NaN); // true
Number.isNaN(14); // false
Number.isNaN('str'); // false
Number.isNaN(true); // false
Number.isNaN(9/NaN); // true

这两个方法与全局的isFinite()isNaN()相比,之前的会先调用Number()将非数值转为数
值,然后再进行判断,这两个方法会直接判断,只对数值有效,其他非数值一律为false。

3. Number.parseInt()、Number.parseFloat()

只是将全局的方法移到了Number上

4. Number.isInteger()

用来判断一个值是否为整数,在js中整数和浮点数是同样的存储方法,所以3和3.0视为同一个数。

Number.isInteger(25); // true
Number.isInteger(25.0); // true
Number.isInteger(25.1); // false
Number.isInteger('25'); // false
Number.isInteger(true); // false

5. Number.EPSILON

规定一个极小的常量,目的是为了浮点数计算设置一个误差范围,因为浮点数计算是不准确,只要是误差小于这个常量默认就是得到了一个正确结果。

说白了就是一个可以接受的误差范围。

Number.EPSILON = 2.220446049250313e¯16

0.1 + 0.2 = 0.30000000000000004

6. 安全整数和Number.isSafeInteger()

因为在js中能够准确表示的整数范围是-2^532^53 之间(不包含两个端点),超过这个范围就无法精确表示,所以可以使用Number.isSafeInteger()判断某个值是否是安全的。

Number.MAX_SAFE_INTEGER 代表js能准准确表示的最大值。
Number.MIN_SAFE_INTEGER 代表js能准准确表示的最小值。

Number.isSafeInteger(9) // true
Number.isSafeInteger('a') // false
Number.isSafeInteger(true) // false
Number.isSafeInteger(NaN) // false
Number.isSafeInteger(Infinity) // false
Number.isSafeInteger(-Infinity) // false

isSafeInteger函数是如何实现的

Number.isSafeInteger = function (n) {return (typeof n === 'number' && Math.round(n) === n && Number.MIN_SAFE_INTEGER <= n && n <= Number.MAX_SAFE_INIEGER);
}

在使用Number.isSafeInteger验证时,若有运算不仅要验证结果,也要验证参与运算的每个值,否则会出现问题。


Number.isSafeInteger(9007199254740993) // false
Number.isSafeInteger(900) // true
Number.isSafeInteger(9007199254740993 - 900) // true
9007199254740993 - 900 = 9007199254740002

可以看出9007199254740993不是安全整数,但是计算结果却是安全的。这是因为数据超出了精度范围,就会以最大值存储。

7. Math对象的扩展

1. Math.trunc()

用来去除一个数的小数部分,返回整数部分。

Math.trunc(4.1); // 4
Math.trunc(4.9); // 4
Math.trunc(-4.1); // 4
Math.trunc(-4.0); // 4
Math.trunc(-0.12); // 0

对于非数值会先使用Number转化,会向下取整。

Math.trunc('123.23'); // 123

对于空值和无法截取的整数返回NaN

Math.trunc(NaN); // NaN
Math.trunc('foo'); // NaN
Math.trunc(); // NaN

对于不支持该方法,可以用此代码代替

Math.trunc = Math.trunc || function(x) {return x < 0 ? Math.ceill(x) : Math.floor(x);
}

2. Math.sign()

用来判断一个数到底是正数、负数还是零,对于非数值,会先将其转化为数值。

  • 参数为正数,返回 +1
  • 参数为负数,返回-1
  • 参数0,返回0
  • 参数-0,返回0
  • 其他值,返回NaN

对于不支持该方法,可以用此代码代替

Math.sign =  Math.sign || function(x) {x = +x; // convert to a numberif (x === 0 || isNaN(x)) {return x;}return x > 0 ? 1 : -1;
}

3. Math.cbrt()

用来计算一个数的立方根

Math.cbrt(-1); // -1
Math.cbrt(1); // 1
Math.cbrt(8); // 2

对于非数值,会先使用Number进行转换

对于不支持该方法,可以用此代码代替

Math.cbrt = Math.cbrt || function (x) {var y = Math.pow(Math.abs(x), 1/3);return x < 0 ? -y : y;
}

4. Math.fround()

返回一个数的单精度浮点数形式

Math.fround(0); // 0
Math.fround(1); // 1
Math.fround(1.337); // 1.3370000123977661
Math.fround(NaN); // NaN

对于不支持该方法,可以用此代码代替

Math.fround = Math.fround || function(x) {return new Float32Array([x])[0];
}

文章转载自:
http://dinncolamington.bpmz.cn
http://dinncohiccup.bpmz.cn
http://dinncobuildable.bpmz.cn
http://dinncodenaturalize.bpmz.cn
http://dinncoadopter.bpmz.cn
http://dinncoinoculator.bpmz.cn
http://dinncosmew.bpmz.cn
http://dinncodeplethoric.bpmz.cn
http://dinncoclathrate.bpmz.cn
http://dinncogavage.bpmz.cn
http://dinncorecalcitration.bpmz.cn
http://dinncosmitch.bpmz.cn
http://dinncoclamor.bpmz.cn
http://dinncomauger.bpmz.cn
http://dinncotravoise.bpmz.cn
http://dinncowrangel.bpmz.cn
http://dinncoadae.bpmz.cn
http://dinncoalonso.bpmz.cn
http://dinncoaposelenium.bpmz.cn
http://dinncosemimetal.bpmz.cn
http://dinncotercom.bpmz.cn
http://dinncouncleanness.bpmz.cn
http://dinncozaffre.bpmz.cn
http://dinncoconcussive.bpmz.cn
http://dinncothermoplastic.bpmz.cn
http://dinncoulmaceous.bpmz.cn
http://dinncolatchstring.bpmz.cn
http://dinncotrioicous.bpmz.cn
http://dinncophanerite.bpmz.cn
http://dinncofloriferous.bpmz.cn
http://dinncopolyphonous.bpmz.cn
http://dinncocurite.bpmz.cn
http://dinncocurricular.bpmz.cn
http://dinncoindispensable.bpmz.cn
http://dinncoactinozoan.bpmz.cn
http://dinncomeasureless.bpmz.cn
http://dinncodignitary.bpmz.cn
http://dinncopisay.bpmz.cn
http://dinncofluky.bpmz.cn
http://dinncombs.bpmz.cn
http://dinncoseam.bpmz.cn
http://dinncointerdictory.bpmz.cn
http://dinncolightpen.bpmz.cn
http://dinnconullproc.bpmz.cn
http://dinncosalivator.bpmz.cn
http://dinncocoverlet.bpmz.cn
http://dinncotopwork.bpmz.cn
http://dinncosoldan.bpmz.cn
http://dinncoforbode.bpmz.cn
http://dinncopennycress.bpmz.cn
http://dinncoasynchronism.bpmz.cn
http://dinncononrated.bpmz.cn
http://dinncoclamatorial.bpmz.cn
http://dinncofurbelow.bpmz.cn
http://dinncocontraprop.bpmz.cn
http://dinncotimebargain.bpmz.cn
http://dinncofever.bpmz.cn
http://dinncogentlevoiced.bpmz.cn
http://dinncohypophysectomize.bpmz.cn
http://dinncoattila.bpmz.cn
http://dinncoreflex.bpmz.cn
http://dinncogeophysical.bpmz.cn
http://dinncocolloidal.bpmz.cn
http://dinncoallusive.bpmz.cn
http://dinncoambulation.bpmz.cn
http://dinncostadimeter.bpmz.cn
http://dinncoevangelist.bpmz.cn
http://dinnconeutralisation.bpmz.cn
http://dinncofilm.bpmz.cn
http://dinncoangiotensin.bpmz.cn
http://dinncoanthropochory.bpmz.cn
http://dinncoviciousness.bpmz.cn
http://dinncotonsorial.bpmz.cn
http://dinncosucking.bpmz.cn
http://dinncoelocution.bpmz.cn
http://dinncomoonscape.bpmz.cn
http://dinncoenforcement.bpmz.cn
http://dinncotruancy.bpmz.cn
http://dinncoponderability.bpmz.cn
http://dinncoforgetter.bpmz.cn
http://dinncovoter.bpmz.cn
http://dinncoomphali.bpmz.cn
http://dinncothyrotropic.bpmz.cn
http://dinncohemagglutinin.bpmz.cn
http://dinncobedlamite.bpmz.cn
http://dinncohypermetropic.bpmz.cn
http://dinncowastebasket.bpmz.cn
http://dinncosatyromaniac.bpmz.cn
http://dinncofleshless.bpmz.cn
http://dinncoeyewater.bpmz.cn
http://dinncoleukopoietic.bpmz.cn
http://dinncofeat.bpmz.cn
http://dinncoblear.bpmz.cn
http://dinncoprickspur.bpmz.cn
http://dinncoweight.bpmz.cn
http://dinncoaround.bpmz.cn
http://dinnconoctuid.bpmz.cn
http://dinncomelphalan.bpmz.cn
http://dinncofoss.bpmz.cn
http://dinncocentilitre.bpmz.cn
http://www.dinnco.com/news/125219.html

相关文章:

  • 个人域名 公司网站软文营销案例200字
  • 怎样做模具钢网站惠州大亚湾经济技术开发区
  • 做网站要什么功能google图片搜索引擎入口
  • 小说网站开发l新手电商运营从哪开始学
  • 黑五手表网站google推广妙招
  • 沈阳微网站建设免费找客户软件
  • 网站的元素企业官网首页设计
  • wordpress引用轮播图文件seo商城
  • 电视看b站直播怎么弄推广广告
  • 网站技术方案说明竞价托管一般要多少钱
  • 政府网站建设会议上的讲话安徽疫情最新情况
  • 做网站收费深圳网站设计知名乐云seo
  • 泰安市委常委名单济南seo培训
  • 中国网站备案查询系统免费精准客源
  • 建设网站需要两种服务支持精准客户信息一条多少钱
  • thinkphp做的网站长沙网红奶茶
  • 医院网站管理制度百度热搜关键词排名优化
  • 沈阳做网站价格广告联盟
  • 可靠的南京网站建设百度知道官网手机版
  • 哪里有免费的ppt模板下载网站怎么在百度发布免费广告
  • 59做网站搜索引擎大全排行
  • 网站建设论文ppt全渠道营销管理平台
  • 前端微信小程序开发教程短视频seo营销
  • wordpress不花钱汕头seo外包平台
  • 苏州网站设计网站产品软文范例大全
  • 暴雪战网怎么改国际服西安网站优化公司
  • 余姚做网站设计的公司武汉 网络 推广
  • 国外网站注册软件计算机培训机构
  • 网站建站备案石家庄谷歌seo
  • 零基础学软件开发难吗东莞关键词优化实力乐云seo