
es6
斯诺伐克
这个作者很懒,什么都没留下…
展开
-
ES6 数组的拓展
扩展运算符 console.log(1, ...[2, 3, 4], 5) // 1,2,3,4,5 Array.from Array.from方法用于将两类对象转为真正的数组:类似数组的对象(array-like object)和可遍历(iterable)的对象(包括 ES6 新增的数据结构 Set 和 Map) Array.of() Array.of方法用于将一组值,转换为数组 Ar...原创 2019-03-29 14:31:20 · 368 阅读 · 0 评论 -
ES6 对象新增的方法
Object.is() 用来比较两个值是否严格相等,与严格比较运算符(===)的行为基本一致 Object.is('foo', 'foo') // true Object.is({}, {}) // false Object.is(+0, -0) // false Object.is(NaN, NaN) // true Object.assign() Object.assign方法用于对...原创 2019-03-29 14:59:20 · 134 阅读 · 0 评论 -
ES6 Set和Map
Set const set = new Set([1, 2, 3, 4, 4]); //去重 [...set] // [1, 2, 3, 4] add(value):添加某个值,返回 Set 结构本身。 delete(value):删除某个值,返回一个布尔值,表示删除是否成功。 has(value):返回一个布尔值,表示该值是否为Set的成员。 clear():清除所有成员,没有返回值 ...原创 2019-03-29 15:32:14 · 125 阅读 · 0 评论 -
ES7和ES8新特性
Array.prototype.includes() 两个参数:要搜索的值和搜索的开始索引 ['a', 'b', 'c', 'd'].includes('b', 1) // true ['a', 'b', 'c', 'd'].includes('b', 2) // false 求幂运算符(**) let a = 3 a **= 2 // 9 async async fun...原创 2019-03-29 16:44:59 · 316 阅读 · 0 评论 -
ES6 字符串的拓展
includes(), startsWith(), endsWith() includes():返回布尔值,表示是否找到了参数字符串。 startsWith():返回布尔值,表示参数字符串是否在原字符串的头部。 endsWith():返回布尔值,表示参数字符串是否在原字符串的尾部。 let s = 'Hello world!'; s.startsWith('Hello') // true s.e...原创 2019-03-29 11:37:19 · 112 阅读 · 0 评论