by threatofrain · 3y ago · 0 comments
const arr = [1, 2, 3, 4, 5]
for (let i = arr.length - 1; 0 < i; i--) {
const j = Math.floor(Math.random() * (i + 1))
[arr[i], arr[j]] = [arr[j], arr[i]]
} Uncaught ReferenceError: can't access lexical declaration 'j' before initialization
Semicolons aren't that bad.While /, +, and - are rare in the beginning of the statement, ( and [ aren't.
I enjoy teaching this to junior developers as the "winky frown rule" because that is a silly name that sticks in your memory and does help you remember it. Lines that start with an emoticon frown must wink:
;( ;[ ;`