为什么 ["text"] == ["text"] 是假的?

Whys is ["text"] == ["text"] false?

为什么表达式 ["text"] == ["text"] 在 JavaScript 中的计算结果为 false

我直觉地认为这是真的,因为这两个数组是相同的。 JS引擎是否比较两个不同对象的引用,从而返回false,而不是比较数组的内容?

您创建了两个不同的数组,JavaScript 正在比较它们的引用,而不是它们的内容。

const array = [1, 2, 3];

// evaluates to true
console.log(array === array);

// evaluates to false
console.log([1, 2, 3] === [1, 2, 3]);

这是一个关于比较数组内容的非常好的答案:How to compare arrays in JavaScript?