- 유사배열객체
var str = 'harustory'
str[1] = str[1].toUpperCase();
console.log(str)
- 객체의 비교
const obj1 = { name : 'kim', age : 20 }
const obj2 = { name : 'kim', age : 20 }
console.log( obj1 === obj2 )
- 얕은복사 vs 깊은복사
- 얕은복사 : Object.assing(), { … obj }
- 깊은복사 : JSON.stringify(), lodash 라이브러리 (cloneDeep)
const person = {
name : 'Kim',
address : {
city : 'suwon',
postnum : 16336,
}
}
const personA = { ...person }
const personB = JSON.parse(JSON.stringify(person))
// 값을 변경한다고 했을때 순차적으로 실행
personA.name = 'Lee';
personB.name = 'Park';
personA.address.city = 'seoul',
personB.address.postnum = 12345
console.log(person) ??
- 매개변수와 인수
function add(x , y) {
return x + y
}
console.log(add(2,5))
console.log(add(2))
console.log(add(2,'5'))
console.log(add([1,2,3],[4])) // '1,2,34' '1,2,3' + '4'
console.log(add({num : 2},{num : 5}))