{ Javascript snippets }

Wes Bos

Wes Bos @wesbos

🔥 Use the modulus operator in JavaScript to find out if a number has a decimal. You can then use that in Intl.NumberFormat to trim off .00 when displaying prices of whole dollar amounts https://t.co/t59fXDJrAD

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