-
[JS] Object, Array 구분하는 방법Javascript 2020. 9. 8. 10:09
1. typeof를 통해 Object 인지 구분한다(Array, Object 둘 다 Object 로 리턴)
if(typeof(something) == 'object')
2. .constructor로 값을 확인한다
haha = ['hello'];
hihi = {hi:'whassup'};
haha.constructor == Array => true
hihi.constructor == Object => true
'Javascript' 카테고리의 다른 글
ES6 비동기 프로그래밍 변천사(?) callback 지옥부터 async await 까지 (0) 2020.09.15 [javascript]아이디 및 패스워드 정규식으로 제한하기 (0) 2020.05.20 본인 창 닫기 (0) 2020.04.24