How to Use Logical OR for Defaults
a || b when falsy. Fast. But 0 and '' become b.

How to Use Logical OR for Defaults
a || b when falsy. Fast. But 0 and '' become b.

You Can Use Same Variable Name TWICE?!
🔥 NO WAY! Destructuring allows DUPLICATE variable names in the same statement! const {a, a} = obj is VALID JavaScript! Last one silently wins. ESLint doesn't catch this by default. Tag a dev who needs to see this!
#javascript #javascripttricks #codingchallenge #destructuring #javascriptes6 #javascriptquiz #javascriptweird #javascriptwtf #javascriptbugs #codinginterview #codingtips #javascriptshorts

How to Use Proxy to Trap Property Access
Proxy intercepts get/set. Validation. Logging. Magic.

How to Make Array Lookups 1000x Faster
Set has O(1) lookup. Array has O(n). One change. Instant.

How to Prevent setTimeout Drift in Loops
setTimeout inside loops is not precise.

Why does this JavaScript sort put 10 before 2?
Why does this JavaScript sort put 10 before 2 in a leaderboard. The JavaScript code uses sort without a comparator, so numbers are sorted as strings. In JavaScript apps this breaks every numeric ranking.
#whatswrongwiththisjavascriptcode #javascriptbug #javascriptproductionbug #javascriptdebugging #javascriptbackend #javascriptcodereview #javascriptsecurity #javascriptperformance #javascriptreliabili...

What's wrong with this JavaScript parseInt losing digits?
What's wrong with this JavaScript parseInt losing digits on user input. The JavaScript code parses a string without radix, so leading zeros trigger octal in older engines. In JavaScript APIs this corrupts IDs.
#whatswrongwiththisjavascriptcode #javascriptbug #javascriptproductionbug #javascriptdebugging #javascriptbackend #javascriptcodereview #javascriptsecurity #javascriptperformance #ja...

What's wrong with this JavaScript unhandled rejection?
What's wrong with this JavaScript unhandled rejection crashing Node. The JavaScript code returns a promise without catch. In JavaScript unhandled rejections can terminate the process.
#whatswrongwiththisjavascriptcode #javascriptbug #javascriptproductionbug #javascriptdebugging #javascriptbackend #javascriptcodereview #javascriptsecurity #javascriptperformance #javascriptreliability #javascri...

What's wrong with this JavaScript this in callback?
What's wrong with this JavaScript this in a callback losing context. The JavaScript code passes a method as callback and this becomes undefined. In JavaScript event handlers the method loses its instance.
#whatswrongwiththisjavascriptcode #javascriptbug #javascriptproductionbug #javascriptdebugging #javascriptbackend #javascriptcodereview #javascriptsecurity #javascriptperformance #javascriptrel...

What's wrong with this JavaScript async loop?
What's wrong with this JavaScript async loop in a task runner. The JavaScript code uses forEach with async callbacks, so errors and awaits are ignored. In JavaScript services this drops failures and hides retries.
#whatswrongwiththisjavascriptcode #javascriptbug #javascriptproductionbug #javascriptdebugging #javascriptbackend #javascriptcodereview #javascriptsecurity #javascriptperformance #javascript...
