一般我们声明数组有2种方法
let arr1=[];
let arr2=new Array();
console.log(arr1===arr2);//false
console.log(arr1==arr2);//false
为什么?
首先从功能上来说,它们是一致的,但是为什么它们不一致?
我们再来试试下面这个
let a=new Array();
let b=new Array();
console.log(a===b);//false
console.log(a==b);//false
let c=[];
let d=[];
console.log(c===d);//false
console.log(c==d);//false
执行typeof([]),我们就会发现,对应js而言,数组是一个对象,每个对象在创建时都会开辟一个新的存储地址,所以对应对象而言,就算表面上看上去一致,其实js也认为他们不一致