function solution(data, object) {
for( const [key,value] of Object.entries(object)){
if(value === data) return true;
if(typeof value === 'object' && solution(data,value)) return true;
}
return false;
}
for( const [key,value] of Object.entries(object))
객체 자체의 enumerable 속성 [key, value] 쌍의 배열을 반환합니다
key - in
구문과 똑같지만 Object.entries의 performance과 훨씬 뛰어납니다
퍼포먼스차이
if(typeof value === 'object' && solution(data,value)) return true;
soluition(data,object) 함수
: object 안에 data가 있으면 return true, 없으면 return false를 수행합니다
value
가 object
이며 value
안에 data
가 있으면 true를 반환합니다data
가 현재 object
안에 없다는 뜻이므로 false를 반환합니다