Javascript WTF

A site where we can all share in those little WTF moments we enjoy with Javascript

Assigning to and through literals and undefined

> '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

So not only can you assign something to undefined, but it is possible to assign a value through it.