名称 | 宿主 | 类型 | 作用 | ||||||||
isInteger | Number | method | 是不是整数,小数点后为0的也算,比如2.0 | ||||||||
isNaN | Number | method | 是不是NaN | ||||||||
isFinite | Number | method | 是不是非无穷的数字 | ||||||||
parseInt | Number | method | 字符串转整数,原本全局的方法的转移 | ||||||||
parseFloat | Number | method | 字符串转浮点数,原本全局的方法的转移 | ||||||||
Number.isInteger(100); // true
Number.isInteger(100.0); // true
Number.isInteger(100.1); // false
Number.isNaN(123); // false
Number.isNaN(NaN); // true
Number.isNaN("abc"); // false
Number.isNaN([ 'a', 'b', 'c' ]); // false
Number.isFinite(100); // true
Number.isFinite(Infinity); // false
Number.isFinite("100"); // false
Number.parseInt("100.123", 10); // 100
Number.parseInt("100.123", 2); // 4
Number.parseInt("100.123", 8); // 64
Number.parseInt("100.123", 16); // 256Number.parseFloat("100.123"); // 100.123
Number.parseFloat("10PPP0.123"); // 10名称 | 宿主 | 类型 | 作用 | |||||||||
fromCodePoint | String | method | 通过Unicode码点求字符,支持大于0xFFFF编码字符 | |||||||||
codePointAt | String.prototype | method | 获取指定下标字符的Unicode码点,支持大于0xFFFF编码字符 | |||||||||
at | String.prototype | method | 获取指定下标的字符,可正确获取大于0xFFFF编码的字符 | |||||||||
includes | String.prototype | method | 是否包含指定字符串 | |||||||||
startsWith | String.prototype | method | 起始位置是否包含指定字符串 | |||||||||
endsWith | String.prototype | method | 结束位置是否包含指定字符串 | |||||||||
repeat | String.prototype | method | 重复字符串多次 | |||||||||
String.fromCodePoint(97); // "a"
String.fromCodePoint(0x61); // "a"
String.fromCodePoint(19968); // "一"
String.fromCodePoint(0x4e00); // "一"
let str = 'ABCD一二三四';
str.codePointAt(0); // 65
str.codePointAt(4); // 19968
let str = 'ABCD一二三四';
str.at(0); // "A"
str.at(4); // "一"
let str = 'abcde';
str.includes('abc'); // true
str.includes('bcd'); // true
str.includes('bcd', 2); // false
let str = 'abcde';
str.startsWith('abc'); // true
str.startsWith('bcd'); // false
str.startsWith('bcd', 1); // true
let str = 'abcde';
str.endsWith('cde'); // true
str.endsWith('cde', 0); // false
str.endsWith('cde', 5); // true
"abc".repeat(3); // "abcabc"
"123".repeat(4); // "123123123123"
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |