Javascript:为什么设置两个不可变变量相等可以通过“===”测试,而不可变变量则不能?[复制]

Javascript: Why does setting two immutable variables equal pass the '===' test, but immutable not? [duplicate]

提问人:RNdev 提问时间:12/4/2022 更新时间:12/4/2022 访问量:27

问:

let a = "hello"
let b = "hello"
console.log(a === b)

返回 ,但true

let a = ["hello"]
let b = ["hello"]
console.log(a === b)

返回。为什么会这样?false

JavaScript的 不变性 基元类型 易变性 相等运算符

评论


答: 暂无答案