Three ways to distinguish between arrays and objects
Because the type of judgment object and array are both ,typeof
Object
So sometimes it is impossible to tell if the type of a value is an object or an array.
<script type="text/javascript">
var obj = [];
//现在判断 obj 是属于社么类型的值
</script>
1.constructor
The constructor of the array isfunction Array(){...}
The constructor of the object isfunction Object() { ...}
2.instanceof
Check if there is an Array constructor in the prototype chain of obj,
If it returns true, that is, obj is of Array array type.
3.toString
Change the point of this and let the array call Object's to.String method.