Syntax - Tasty Web Development Treats

JS One Liners

Jan 3, 2022
Discover how JavaScript one-liners can streamline coding tasks with quick snippets for generating unique IDs and random colors. The hosts share hilarious anecdotes about their coding adventures while unraveling the nuances of invoice customization and the Temporal API. Explore the intricacies of implicit returns and destructuring to improve debugging, and learn efficient techniques for database entry duplication. Get ready for practical tips that could revolutionize your coding experience!
Ask episode
AI Snips
Chapters
Transcript
Episode notes
ADVICE

Generating Temporary IDs

  • Use Math.random() * 1e15 for temporary, mostly unique IDs.
  • Avoid Math.random() for cryptography; use Node's crypto package instead.
ADVICE

Generating Random Colors

  • Generate random hex colors with '#'+Math.floor(Math.random()*16777215).toString(16).
  • This one-liner comes from Paul Irish.
ADVICE

Clearer Console Logs

  • Log objects with labeled properties for clearer console output.
  • This gives labels to your console.log data.
Get the Snipd Podcast app to discover more snips from this episode
Get the app