ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
## Number - toFixed(x):将数字转换成字符串,x 为保留多少位小数,默认不保留 - toPrecision(x):将数字格式化为指定的长度 ## decodeURI 与 decodeURIComponent 区别 encodeURI() 不会对本身属于URI的特殊字符进行编码,例如冒号、正斜杠、问号和井字号; 而 encodeURIComponent() 则会对它发现的任何非标准字符进行编码。 **因此,在实际情况中,我们一般使用 decodeURIComponent** ## RegExp 有两种语法,一般使用简单的 ``` const reg = /pattern/modifiers pattern: 正则表达式 modifiers: 修饰符 ``` | 修饰符 | 描述 | | --- | --- | | i | 执行对大小写不敏感的匹配 | | g | 执行全局匹配(查找所有匹配而非在找到第一个匹配后停止) | | m | 执行多行匹配 | ``` let phone = '18888888888' if(/^1[3456789]\d{9}$/.test(phone)){ console.log('lalala') } ```