23.ES10

Object.fromEntries

        //二维数组
        const result = Object.fromEntries([
            ['name','Study'],
            ['xueke', 'Java,大数据,前端,云计算']
        ]);

        //Map
        const m = new Map();
        m.set('name','ATGUIGU');
        const result = Object.fromEntries(m);

        //Object.entries ES8
        const arr = Object.entries({
            name: "Study"
        })
        console.log(arr);

trimStart 与 trimEnd

		// trim
        let str = '   iloveyou   ';

        console.log(str);
        console.log(str.trimStart());
        console.log(str.trimEnd());

flat 与 flatMap

        //flat 平
        //将多维数组转化为低位数组
        const arr = [1,2,3,4,[5,6]];
        const arr = [1,2,3,4,[5,6,[7,8,9]]];
        //参数为深度 是一个数字
        console.log(arr.flat(2));  

        //flatMap
        const arr = [1,2,3,4];
        const result = arr.flatMap(item => [item * 10]);
        console.log(result);

Symbol.prototype.description

        //创建 Symbol
        let s = Symbol('Study');

        console.log(s.description);
posted @ 2021-02-05 16:23  AaronHuang  阅读(34)  评论(0编辑  收藏  举报