Calculate all permutations of a JavaScript array or string
Generate all permutations of an array's elements or a string's characters using recursion.
30 seconds of code provides a curated collection of short code snippets for all your development needs. Our collection spans many topics, ranging from simple coding problems to theoretical concepts and development techniques.
Generate all permutations of an array's elements or a string's characters using recursion.
Learn how to add or remove event listeners from elements with ease.
Create a typewriter effect animation with CSS variables and just a sprinkle of JavaScript.
Loading indicators are a staple of modern web design. Here are some CSS loaders to keep your users engaged while they wait.
Learn how to create a list with floating or sticky headings for each section.
Turn requestAnimationFrame()
into a custom hook to animate your React components.
Learn how to split a string into words, using the Intl.Segmenter
API.
Ever wanted to initialize an array with a sequence of generated values? Here's a few ways to do it.
Learn everything you need to know about JavaScript's call()
, apply()
and bind()
in this short guide.
Enums are part of TypeScript, but what about defining enums in plain old JavaScript? Here are a few way you can do that.
JavaScript arrays have a very robust API offering some amazing tools. Learn the 4 must-know JavaScript array methods in this quick guide.
Make your HTML documents more SEO-friendly by including these lines in your <head>
element.
Reviewing CSS code is a skill that takes time to master. Here are some tips from my personal experience to help you get started.
I hand picked 10 of my favorite CSS background patterns from MagicPattern for your next project. Get them now!
Learn how to persist state in React using hooks and localStorage
or sessionStorage
.
Learn how to create your own lazy loading image component in React.
JavaScript's this
keyword can confuse beginners and veterans alike. Learn how it works in different scenarios and start using it correctly.
Maps and objects are very similar, but they have some differences that can help you decide which one better fits your use-case.
Did you know you can get the index of an array item in a JavaScript for...of loop? Learn how with this bite-sized tip.
Function arity is a simple, yet useful concept in functional programming, especially when combined with currying.
Currying is a process that transforms a function that takes multiple arguments into a series of functions that each take a single argument.
JavaScript uses callback functions quite a lot. From event listeners to asynchronous code, they're an invaluable tool you need to master.
Ever wanted to listen for multiple events on an element and handle them with the same function? Here's how!
Create a progress bar indicating the scroll percentage of the page, using CSS and JavaScript.