- Object.assign
<script>
/*
Object.assign({},obj1,obj2) 对象的合并
*/
var obj1 = {
id: 1,
name: '张三'
}
var obj2 = {
sex: 'man',
age: 18
}
var obj3 = Object.assign({},obj1,obj2)
console.log( obj3 )
</script>
//输出结果:{id: 1, name: "张三", sex: "man", age: 18}
2.Object.keys
<script>
var obj = {
id: 1,
name: '王麻子',
sex: 'man',
age: 50
}
var arr = Object.keys( obj )
console.log( arr )
</script>
//输出结果:["id", "name", "sex", "age"]
3.Object.values
<script>
var obj = {
id: 1,
name: '王麻子',
sex: 'man',
age: 50
}
var arr = Object.values( obj )
console.log( arr )
</script>
//输出结果:[1, "王麻子", "man", 50]