1.函数属性声明简化
var obj = {
name:'andy',
age:20,
getAge(){
console.info(this.age);
}
}
obj.getAge(); //20
2.对象简化写法1
function getAge(age){
return {age};
}
getAge(18); //{age:18}
3.对象简化写法2
function getAge(){
var age = 18;
return {age}; //{age:18}
}
getAge()
4.变量作属性名
var propKey = 'flag';
var obj = {
[propKey]: true,
['a'+'bc']: 123
};
5.属性拷贝
var src1 = {a:1};var target = {};
var extend = Object.assign(target,src1);
target === extend // {a:1} 返回target
Object.is(target,extend)
6.判断对象是否相等
Object.is(obj1,obj2)
Object.is(NaN ,NaN) // true
NaN === NaN // false
refer:
1.http://www.jianshu.com/p/1c8270bdf0ee