Difference between array and object in javascript? or Array Vs Object

前端 未结 4 1638
梦毁少年i
梦毁少年i 2021-02-07 15:08

How to recognize array & object in js where typeof doesn’t come in handy?

 var arr = [], ob = {};

As everything in js are objects,

4条回答
  •  失恋的感觉
    2021-02-07 15:36

    Among numerous simple/sophisticated comparisons, one difference is:

    var arr = []; # arr.length => 0

    var obj = {}; # obj.length => undefined

提交回复
热议问题