Bubble sort
Sort an array of numbers, using the bubble sort algorithm.
30 seconds of code contains a curated collection of code articles covering a wide range of development needs. The collection spans many topics, ranging from simple coding problems to theoretical concepts and development techniques.
Sort an array of numbers, using the bubble sort algorithm.
Create a cool effect that fades out the siblings of a hovered item with a few lines of CSS.
Having trouble loading an image? Display a fallback message instead!
Ever wanted to change the title of a page in a React app? You can create a custom hook to do just that.
Use this little trick to create an error dispatcher in React.
Ever wanted to show the password the user is typing? Here's how you can create a password input field with a reveal button in React.
Quickly and easily check if a string is a yes/no answer to a boolean question in your CLI programs.
Learn how to type check for different types of streams in Node.js.
String splitting and truncation, both simple and locale-sensitive are possible in JavaScript. Learn how in this guide.
Learn how to get the first or last N elements of a JavaScript array, using Array.prototype.slice()
.
Circular JSON objects can't be serialized using JSON.stringify()
, but you can use this trick to handle them.
Injecting CSS into a page via JavaScript is pretty easy, if you know how to leverage the DOM.
Freezing objects is not the only way to prevent mutations. Learn how you can leverage the Proxy object to your advantage.
Learn how to redirect the page to HTTPS if it's currently in HTTP.
Learn how to execute a function for each element of an array, starting from the last one.
Create a debounced function that waits a certain amount of time before invoking the provided function again.
Create a function that ensures another function is called only once.
Have you ever tried appending elements to an array in JavaScript? Here's a primer on all the available options.
Adding a key-value pair to a JavaScript object is straightforward, yet there are multiple ways available to do so.
Having trouble deleting branches in Git? Here's a guide to help you delete local, remote, detached, and merged branches.
Run a callback at most once when a condition becomes true, using a custom React hook.
JavaScript's switch
statement often feels hard to remember and a little bit out of place. Maybe it's time to use object literals, instead.
Get all the partial substrings of a string in JavaScript using generator functions.
JavaScript ES6 introduced us to powerful new features, such as the spread and rest syntax. Learn all you need to know in this quick guide.