es7求幂运算符和es8简单介绍数组
es7求幂运算符:prototype
求幂运算符 ** operator (求幂运算符)code
console.log(2**3); //打印8; console.log(4**3); //打印64; console.log(Math.pow(2,3));//打印8; console.log(Math.pow(4,3));//打印64;
Array.prototype.includes字符串
let a = [1,2,3]; console.log(a.includes(5));//打印false; //includes:判断数组里面有没有那个值;
es8:console
padStart:es7
//在字符串前面填充: 'es8'.padStart(2); // 打印'es8'; 'es8'.padStart(5); // 打印' es8'; 'es8'.padStart(6, 'woof'); // 打印'wooes8'; 'es8'.padStart(14, 'wow'); // 打印'wowwowwowwoes8'; 'es8'.padStart(7, '0'); // 打印'0000es8';
padEnd:es8
//在字符串后边填充: 'es8'.padEnd(2); // 打印'es8'; 'es8'.padEnd(5); // 打印'es8 '; 'es8'.padEnd(6, 'woof'); // 打印'es8woo'; 'es8'.padEnd(14, 'wow'); // 打印'es8wowwowwowwo'; 'es8'.padEnd(7, '6'); // 打印'es86666'; //注释:其中第一个参数是目标长度,第二个参数是填充字符串,默认的值是空格。
Object.values:注释
let obj = { x: 'xxx', y: 1 }; Object.values(obj); // 打印['xxx', 1]; let obj = ['e', 's', '8']; Object.values(obj); // 打印['e', 's', '8']; Object.values('es8'); // 打印['e', 's', '8']; const obj = { 10: 'xxx', 1: 'yyy', 3: 'zzz' }; Object.values(obj); // 打印['yyy', 'zzz', 'xxx']; //注释:若是是纯 number 型的键值,则返回值顺序根据键值从小到大排列;