{ Javascript snippets }

Caleb Porzio

Caleb Porzio @calebporzio

🔥 Super clean little way to disable submit buttons while a form is posting 👌 Just learned that you can reference an input element in the handler by "name" (no long document.querySelector) 🙌 (Video in reply) https://t.co/BqhOETXIq5

Wes Bos

Wes Bos @wesbos

👆🏻Intl is aware of language differences, so it will either detect or be passed a language tag. Swedish uses ä as the 28th letter, so it respects that: https://t.co/pf6agoYxZV

Kent C. Dodds 🧢

Kent C. Dodds 🧢 @kentcdodds

🔥 Put this in your jest test setup file: afterEach(() => { jest.clearAllMocks() }) Helps ensure your tests are properly isolated.

Rich Harris

Rich Harris @Rich_Harris

just learned a neat trick from the Three.js source code: if you want to remove an item from an array whose order doesn't matter, don't do this... array.splice(index, 1); // slooooowwwww ...do this: array[i] = array[array.length - 1]; array.pop(); // orders of magnitude faster!

Jason Beggs

Jason Beggs @jasonlbeggs

🔥 This is a super-handy alias I found out about a while ago. It deletes all the node_modules folders inside your projects. Run this in your sites/code directory and watch your disk space reappear! https://t.co/JECVNWvnuI

R. Alex Anderson ?

R. Alex Anderson ? @ralex1993

??? #JavaScript tip: Reduce an array of constants into an object to save yourself a couple lines of code. I'm using linear interpolation here to create an array of x,y,z values from a location, destination, and the movement time. https://t.co/0wlocaJLWu