DevDojo
Read post

16+ JavaScript snippets to save your time

This is useful if you're having a situation like this: formatFn("string") + formatFN ("string") Instead of doing that, you can use the power of ES6's raw string syntax. You can use this snippet to generate a tree of depth from depth. Find me on GitHub and Twitter and find me on Facebook and Twitter to find out what you want to do.

Aug 31, 2022•4m read time•From devdojo.com
Post cover image
Table of contents
Detect if dark modeCopy to clipboardMake items in an array uniqueGet random numberGet random hex colorShuffle arrayLoop a function x timesGet random element from arrayGet random stringGet random booleanGet random number between two numbersGet cookieClear all cookiesScroll to top of elementGet average of numbersValidate emailValidate objectChunk arrayRGB to HEXRaw String to normal stringCompare two objectsGet selected textGet object of query params in the urlConvert number to wordCount number of duplicates in arrayGenerate tree from depthConclusion
57 Impressions4 Comments
DevDojo's image
DevDojo

DevDojo serves as a learning platform for developers, offering insights into web development, softw...

33 Followers

•

1 Upvotes

posandu's user avatar
Posandu Mapa
@posandu
Joined Nov 25. 2021
4.7K

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard