Javascript
[JS] Object, Array 구분하는 방법
for2gles
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