How to remove http:// or https:// from a URL in JavaScript

The recommended way to remove http or https from an URL in Javascript is to use the built-in URL object and access the various parts of the URL that way. Alternatively, you can use the String.replace() function with a regular expression and replace it with an empty string. Use the built-in URL object (recommended) The … Read more

How to Round to 2 Decimal Places in Javasacript

There’s a couple different ways to round to two decimal places in Javascript. Which one you use will depend on your situation. Use Math.round The best way to do this is using Math.round, especially if you still need a number on the other end to do math on. Here is the most accurate and correct … Read more

Javascript: How to filter an array of objects by property

A very common task in Javascript (and lots of other programming languages) is creating a subset of an array. Luckily, there’s lots of ways available to do this in Javascript. We’ll go over each from best (Array.filter) to worst (for loop). Use the Array.filter method Filtering an array of objects in Javascript can be done … Read more