对象扩展
//es5写法
{
let l = 1,k = 3;
let es5 = {
l: l,
k: k
}
console.log(es5);
}
输出结果:{l: 1, k: 3}
//es6
{
let l = 1, k = 4;
let es6 = {
l,
k
}
console.log(es6);
}
输出结果:{l: 1, k: 4}
{
//属性表达式
let a = 'b';
let es5_obj = {
a: 'c',
b: 'c'
};
let es6_obj = {
[a]: 'c'
}
console.log(es5_obj,es6_obj)
}
输出结果:{a: "c", b: "c"} {b: "c"}
{
//新增api
console.log('字符串',Object.is('abc','abc'),'abc' === 'abc');
console.log('数组',Object.is([],[]),[] === []);
console.log('拷贝',Object.assign({a: 'a',b: 'b'}));
}
输出结果:字符串 true true
数组 false false
拷贝 {a: "a", b: "b"}