// *******************************************************
// 깊은복사
// *******************************************************
const obj = {id: 'test', password: '123'}
const clonedObj = JSON.parse(JSON.stringify(obj));
const isEqual = obj === clonedObj // false
// *******************************************************
// Array 판별
// typeof Object
// *******************************************************
const arr = [1, 2, 3, 4]
const type = typeof arr // object
const isArray = Array.isArray(arr) // true
const isArray2 = Array.isArray(obj) // false
// TODO isArray가 Obj의 내장속성 아니였나??
// arr.isArray >>> undefined
// DONE Array.isArray(arr)
// *******************************************************
// 빈 obj 검사
// *******************************************************
const isEmpty = JSON.stringify(obj) === '{}'
const isEmptyArr = Array.isArray(arr) && !arr.length > 0
// *******************************************************
// Object property
// *******************************************************
const person = {}
person.name = 'Bob'
person.age = 20
// Object 생성자
// function 대문자 시작
function Person(name, age) {
this.name = name
this.age = age
}
const person1 = new Person()
// {name: undefined, age: undefined}
// default값 지정 Type1
function Person() {
this.name = name || '철수'
this.age = age || 13
}
// default값 지정 Type2
// DONE 초기화 Type2가 더 적절해보임
function Person(name = '철수', age = 13) {
this.name = name
this.age = age
}
// *******************************************************
// TODO ~
// *******************************************************