为什么===和==给予假的跟随?

yaj*_*jiv 1 javascript

我知道这是非常愚蠢的问,但任何人都可以告诉我为什么===和==给予假的跟随.

x=[[1,2]];
console.log(x[0]===[1,2]);
console.log(x[0]==[1,2]);
Run Code Online (Sandbox Code Playgroud)

这里typeof(x [0])和typeof([1,2])也是一样的,那么为什么它给出了假?

Ele*_*Ele 5

因为它们在记忆中是不同的值.

x=[[1,2]];
console.log(x[0]===[1,2]); // Here you're creating a new array in memory
console.log(x[0]==[1,2]); // Here you're creating a new array in memory

var y = x[0]; //Same value in memory

console.log(x[0]===y);
console.log(x[0]==y);
Run Code Online (Sandbox Code Playgroud)

平等比较和相同