1. 对象扩展方法Object.fromEntries()
1.1 传入二维数组 将数组转换成对象
const rs = Object.fromEntries([
['name','zs']
]);
console.log(rs);
1.2 传入map
const map = new Map();
map.set("name",'ls')
const result = Object.fromEntries(map)
console.log(result);
const arr = Object.entries({
"name":"w5"
})
console.log(arr);
2.trimStart和trimEnd
2.1trimStart
let str = " i love you"
console.log(str.trimStart())
console.log(str.trim());
2.2 trimEnd
let str = " i love you"
console.log(str.trimEnd())
console.log(str.trim());
3.flat与flatMap
3.1 flat
const arr = [1,2,3,4,[5,6]]
const arr1 = arr.flat()
console.log(arr1);
const arr2 = [1,2,3,4,[5,6,[7,8]]]
const arr3 = arr2.flat(2)
console.log(arr3);
3.2 flatMap
const arr4 = [1,2,3,4];
const arr5 = arr4.flatMap(item => [item*10])
console.log(arr5);
4.Symbol.prototype.description
获取Symbol('xxx')里的xxx值
let s = Symbol('213')
console.log(s.description);