const user = {
name: 'Heropy',
age: 85,
email: 'thesecon@gmail.com'
}
const {name: heropy,age,email,address= 'Korea'} = user
console.log(`${heropy}의 나이는 ${age}세입니다.`)
const fruits = ['Apple', 'Banana', 'Cherry'] 배열
const [a,b,c,d] = fruits
console.log(a,b,c,d) // Apple Banana Cherry undefined
const fruits = ['Apple', 'Banana', 'Cherry']
console.log(...fruits) // Apple, Banana, Cherry
function toObject(a,b,c) {
return {
a: a,
b: b,
c: c
}
}
console.log(toObject(...fruits)) // {a:"Apple", b: "Banana", c: "Cherry"}
const copyUser = Object.assign({}, user) 얕은 복사
const copyUser = {...user} 얕은 복사
깊은 복사
import lodash from 'lodash'
import _ from 'lodash'
const copyUser = _.cloneDeep(user)