Table of contents:
Tag: Javascript
-
Include a JavaScript file in another file
Including a JavaScript file into another file is a very nice thing to be able to do. It’s something you probably do with almost every other language; it helps keeping files smaller, more readable, and of course, more readable. There are multiple ways to accomplish this and I’ll let you pick the one that works best for you without using the Javascript string replace() function.
-
Why you should use strict with JavaScript
Many people “dislike” JavaScript for reasons that I cannot understand. I like it and it serves a purpose. JavaScript can be a very forgiving language. By that I mean it let’s you get a way with things that other languages, that are a little stricter, would not. This is where the “use strict” comes into play.
-
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.