분류 javascript

Javascript 30초 Snippet - Type : isObjectLike

컨텐츠 정보

  • 조회 349 (작성일 )

본문

값이 객체와 같은지 확인합니다.


https://github.com/30-seconds/30-seconds-of-code 


제공된 값이 null이 아니고 typeof가 'object'와 같은지 확인하십시오.


const isObjectLike = val => val !== null && typeof val === 'object';


ex)


isObjectLike({}); // true
isObjectLike([1, 2, 3]); // true
isObjectLike(x => x); // false
isObjectLike(null); // false