这篇翻译不完整。请帮忙从英语翻译这篇文章

概述

Number.parseInt() 方法可以根据给定的进制数把一个字符串解析成整数。

语法

Number.parseInt(string[, radix])

 

// radix为指定基数,说明字符串为多少进制的数字表示。

let strObj = '0110';

console.log(Number.parseInt(strObj, 2)); // 6

console.log(Number.parseInt(strObj, 10)); // 110

 

参数

描述

该方法和全局的 parseInt() 函数是同一个函数:

Number.parseInt === parseInt; // true

请移步全局函数 parseInt() 页面查看更多的解释和示例。

Polyfill

Number.parseInt = parseInt;

规范

规范名称 规范状态 备注
ECMAScript 2015 (6th Edition, ECMA-262)
Number.parseInt
Standard 初始规范.
ECMAScript Latest Draft (ECMA-262)
Number.parseInt
Draft  

浏览器兼容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic supportChrome Full support YesEdge Full support YesFirefox Full support 25IE No support NoOpera Full support YesSafari Full support 9WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 25Opera Android Full support YesSafari iOS Full support 9Samsung Internet Android Full support Yesnodejs Full support 0.12

Legend

Full support  
Full support
No support  
No support

相关链接

文档标签和贡献者

此页面的贡献者: NiLinli, iugo, ziyunfei, tiansh
最后编辑者: NiLinli,