It’s quite often that I have an array of elements and when a certain condition happens that I need to remove a particular element from my JavaScript array. Let’s explore how indexOf and splice accomplish this.
Category: Development
-
C# Improving string.IsNullOrEmpty readability
I often find myself using this great C# function: string.IsNullOrEmpty. It is the assured way to confirm whether a string is empty – null or otherwise. However, I often find myself wanting to know when it is not empty, so I wrote an string extension named HasValue.
-
C# OutputCache with subdomains
The other day I was working on a project that was leveraging OutputCache. This little attribute is a fantastic way to implement caching in an MVC project. This was working great until I encountered a snag when using a subdomain.
-
Difference between location.href and location.replace
It’s quite common to redirect a user visiting your webpage with javascript location href, more specifically when they perform an action, such as: clicking a button. When the user completes the action and you want to redirect the user to somewhere else, you have two common choices: window.location vs window.location.href
(more…) -
Retrieving query string variables with JavaScript
This is not something I use everyday. Seems more like a once a year thing. Last time I needed to extract query string variables, I used the old school approach with a regular expression. Now that I need to do this again, I can use the new school approach: URLSearchParams.
The URLSearchParams (at the time of writing) is not yet standardized in the W3C; however, most modern browsers recognize it. I’ve also got a version of this for how-to Access query string parameters with Express and Node.js.