@JavaScriptBuzz

9 Followers
2 Following
217 Posts
Your daily hit of JavaScript hacks, fixes, and mind popping tricks

How to Use Logical OR for Defaults

a || b when falsy. Fast. But 0 and '' become b.

#javascript #logicalor #defaults #howto

https://www.youtube.com/watch?v=4JocukAzK4w

How to Use Logical OR for Defaults #javascript

YouTube

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

https://www.youtube.com/watch?v=1fs8zval7Hk

You Can Use Same Variable Name TWICE?! #codingchallenge

YouTube

How to Use Proxy to Trap Property Access

Proxy intercepts get/set. Validation. Logging. Magic.

#javascript #proxy #trap #howto

https://www.youtube.com/watch?v=Ih7sfWhFl3w

How to Use Proxy to Trap Property Access #howto

YouTube

How to Make Array Lookups 1000x Faster

Set has O(1) lookup. Array has O(n). One change. Instant.

#javascript #set #performance #lookup #howto

https://www.youtube.com/watch?v=eVKgh1Rz2e8

How to Make Array Lookups 1000x Faster #howto

YouTube

How to Prevent setTimeout Drift in Loops

setTimeout inside loops is not precise.

#javascript #settimeout #timers #bug #howto #timing

https://www.youtube.com/watch?v=k__sDjKo21Q

How to Prevent setTimeout Drift in Loops #howto

YouTube

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

https://www.youtube.com/watch?v=L7zOu_uaOD4

Why does this JavaScript sort put 10 before 2? #javascriptengineering

YouTube

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

https://www.youtube.com/watch?v=0UH6ovX9Wig

Whats wrong with this JavaScript parseInt losing digits? #javascriptreliability

YouTube

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

https://www.youtube.com/watch?v=WNVyPa2flyM

Whats wrong with this JavaScript unhandled rejection? #javascriptreliability

YouTube

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

https://www.youtube.com/watch?v=qlsIaL1zSSA

Whats wrong with this JavaScript this in callback? #javascriptclass

YouTube

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

https://www.youtube.com/watch?v=6NGGecXhFY4

Whats wrong with this JavaScript async loop? #javascriptconcurrency

YouTube