TIL | Reference Types & Equality Testing


Double equals(==) and Triple equals(===) are just going to check for the reference in memory.
==および==は、メモリで参照を検証するだけです.
'hi' === 'hi' // true

['hi', 'bye'] === ['hi', 'bye'] // false
[1] === [1] // false
[1] == [1] // false
[] == [] // false

JavaScript actually doesn't care about what's inside, at least with arrays.
JAvascriptは実際には、少なくとも配列の中に何が入っているのか気にしない.
What it's comparing instead are the references in memory.
逆に、比較はメモリの参照です.
let luckyNum = 87;

[1, 2, 3] === [1, 2, 3] // false

let nums = [1, 2, 3]
let numsCopy = nums;

nums // [1, 2, 3]
numsCopy // [1, 2, 3]

nums.push(4) // 4
nums // [1, 2, 3, 4]

numsCopy // [1, 2, 3, 4]  // ???

numsCopy.pop() // 4

nums // [1, 2, 3]
numsCopy // [1, 2, 3]

nums === numsCopy // true
It's not going to help us if we're trying to compare the contents.
javascriptでコンテンツを比較しようとするのは役に立ちません.