{ Javascript snippets }

Umar Hansa

Umar Hansa @umaar

Little JavaScript snippet to see what all those .toThing() methods do on a Date object: Object.getOwnPropertyNames(Date.prototype) .filter(name => name.startsWith('to')) .map(method => `${method}: ${(new Date())[method]()}`) https://t.co/3H8XcZbgja

Wes Bos

Wes Bos @wesbos

🔥Default function arguments can fallback to a function. This won't be run at definition time, but only once the function is called and no argument is provided. In this case, Math.random() returns a new random number each time https://t.co/xtrn822CEN

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