'abc'[1] = 'B' // this does NOT modify the 'abc' string literal (so far so good) but returns 'B'
let B = 'abc'[1] = 'B' // so this does actually assign 'B' to B"
undefined = 'B' // this does not change undefined (so far so good) but also returns 'B'
let B = undefined = 'B' // so this does actually assign 'B' to B", through undefined
The = operator returns the right-hand side. let B = undefined = 'B' is not assigning undefined to B, it is assigning the rightmost-hand side of the assignment to both.
The real issue is that assigning to undefined etc. isn't a TypeError.
The
=operator returns the right-hand side.let B = undefined = 'B'is not assigningundefinedtoB, it is assigning the rightmost-hand side of the assignment to both.The real issue is that assigning to
undefinedetc. isn't aTypeError.