编程语言
首页 > 编程语言> > javascript – 为什么使用Number.parseInt而不是parseInt()?

javascript – 为什么使用Number.parseInt而不是parseInt()?

作者:互联网

documentation开始:

This method behaves identically to the global function parseInt()

但是,由于它是实验性的,the compatibility是最糟糕的.例如,在IE或Safari中不可用.

那么,为什么开发人员应该使用Number.parseInt()?

解决方法:

使用Number.parseInt鼓励overparseInt()是由于JavaScript社区中的趋势远离使用全局变量. Number.parseInt上的Mozilla文档说明:

…and is part of ECMAScript 2015 (its purpose is modularization of globals).

你有它.这是因为全球恐惧症:)

标签:javascript,ecmascript-6,built-in
来源: https://codeday.me/bug/20190609/1205997.html