![【es6】es6使用集锦 【es6】es6使用集锦](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
一、查找数组中是否包含某个元素 使用includes ,返回值为布尔值
arr.includes(searchElement, fromIndex);
解析:searchElement 查询元素
fromIndex 开始查找的索引位置
demo:
[2, 9, 7, 8, 9].includes(9); //true
二、合并对象 使用Object.assign()
语法: Object.assign(target, …sources) target: 目标对象,sources: 源对象