How does JavaScript's prototypal inheritance differ from classical inheritance?
Understanding the difference between these two object-oriented programming paradigms is key to taking your skills to the next level.
The JavaScript snippet collection contains a wide variety of ES6 helper functions. It includes helpers for dealing with primitives, arrays and objects, as well as algorithms, DOM manipulation functions and Node.js utilities.
Understanding the difference between these two object-oriented programming paradigms is key to taking your skills to the next level.
Clamping and mapping a number to a range are two common and easily confused operations. Learn how to perform each in JavaScript.
JavaScript developers often get confused by JavaScript's variables and scope. Here's a quick guide to understanding these concepts.
Learn how to swap the values of two variables in JavaScript using a single line of ES6 code.
Enhance JavaScript's Math.random()
to generate a random number or integer in a specified range.
Strings in JavaScript can be escaped in various ways. But how do you prevent a string from being escaped? Here's a handy trick for that.
Calculate the coordinates of the current scroll position in the browser window using JavaScript.
Given two pairs of latitude and longitude coordinates, you can calculate the distance between them using the Haversine formula. Let's find out how.
Learn how to detect undefined
object properties in JavaScript the correct way.
Ever needed to convert a decimal number to hexadecimal? Here's a quick and easy way to do it.
How JavaScript handles passing data is a source of confusion and bugs for many developers, especially when it comes to object types.
Learn how to leverage partial application to improve the reusability of your JavaScript functions.
Check if a value can be safely converted to a number in JavaScript.
Learn how to insert an HTML string before or after the start of a specified element using JavaScript.
Learn how to calculate the Hamming distance between two values.
If you've ever needed to check if the bottom of the page is visible, this snippet will help you do just that.
Calculate the number of ways to choose k items from n items without repetition and without order.
Check if any or all the elements in an array are included in another array.
Learn how to pluralize a string in JavaScript based on a number.
Get started with logical operations in JavaScript with this collection of helper functions.
Easily convert between a JavaScript Date object and a Unix timestamp.
Wrap a function call in a try...catch
block to handle errors and return the result or the caught error object.
JavaScript has three different empty states for variables. Learn their differences and how you can check for each one.
Check if localStorage
or sessionStorage
is enabled in the browser, using a simple JavaScript function.