{ Javascript snippets }

Minko Gechev

Minko Gechev @mgechev

JavaScript tip: did you know you can listen for a *single occurrence* of an event using addEventListener? You can specify a configuration object as a third parameter. https://t.co/R0JwOMueVi

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.