1、对象扩展 -> 属性简写、可计算属性、扩展静态方法;
(1).属性简写:let obj = { a: a; test: function(){} }; -> let obj = { a; test(){} };//省略:function
(2).常见静态方法:Object.is(a,b);Object.assign(); Object.getPrototypeOf();/setPrototypeOf(); Object.keys();/values();/entries();//此三个属性获取对象属性、属性值确实方便很多,原生实现采取的 for(var prop in obj){ console.log(obj[prop]) };


2、解构赋值
原生方法:resData = { director:'skr', imgs: [], casts: {} };// let director = resData.director; 解构赋值在其基础上进行优化,解构过程中同时具备变量声明和赋值两个功能;
(1).解构对象 -> let {director,imgs,casts} = resData = {director:'skr',imgs: [],casts: {}}

(2).解构数组 -> let [x,y,z] = arr;//let {x,y,z} = arr;不能成功解析

网友评论