What’s the difference between declaring a constant or variable and assigning it a value? Here’s everything you need to know.
Category: JavaScript
How to Get URL Parameters in JavaScript
How to get all or one of the parameters from the URL of the current page in JavaScript with vanilla JavaScript.
How to Get the Page Path in JavaScript
This tutorial will show you how to get the current page path in JavaScript (and more).
How to Get the Current Domain Name in JavaScript
This tutorial will show you how to get the current domain name in JavaScript (and more).
How to Declare a Global Variable in JavaScript
The two ways to declare a global variable in JavaScript, inside and outside of a function.
Remove Special Characters From a String in JavaScript
Remove special characters from any string with the String.replace() method and well-written RegEx. We show you how!
What Is a Data Layer?
A web developer’s introduction to the data layer, a must-have for advertising and marketing on websites and web applications.
Event Listeners for Multiple Elements in JavaScript
Here’s how to add an event listener for multiple DOM elements in JavaScript.
How to Get the Href of a Clicked Link in JavaScript
Learn how to get the href attribute of any, or specific, clicked links in JavaScript.
How to Get the Class of a Clicked Element in JavaScript
Learn how to get the class of any, or specific, DOM element that the user clicks by creating an event listener.
How to Get the ID of a Clicked Element in JavaScript
Learn how to get the id of any, or specific, DOM element that the user clicks by creating an event listener.
Array to String Without Commas in JavaScript
How to convert an array into a string without commas with the Array.join() method in JavaScript.
How to Run JavaScript on a Mac (4 Ways)
Want to run JavaScript code on your Mac? Here’s how to do it in the Terminal and from your browser.
Check If a String Has Only Numbers in JavaScript
So you need to implement validation for your app’s frontend or backend. Here’s how to do it with RegEx.
Removing All Commas From a String in JavaScript
So you need to remove commas from a string in JavaScript? These are the two best ways to achieve this.
Create an Array of Images in JavaScript (Tutorial)
The best ways to create and use arrays of images in JavaScript.
Check If a Button Is Clicked in JavaScript
This is the best way to listen to click events for a button element.
Is Inline JavaScript Bad?
Wondering whether to inline your JavaScript code or load it externally from a file? We help you decide.
Why Is My JavaScript Not Working? (With Examples)
We round up the most common causes for your JavaScript code not working.
Log the User Out on Closing the Browser in JavaScript
Want to log out your user after they’ve closed the tab or window? Here’s how you could do this in JavaScript.
Set an Attribute Without a Value in JavaScript (Tutorial)
The best ways to set an empty attribute to one or multiple DOM elements in your HTML markup, with plain JavaScript.
Remove Quotes From String in JavaScript
We look at the simplest, most straightforward way to remove quotes from a string in JavaScript.
Pass PHP Array to JavaScript (Tutorial)
It turns out you can get PHP and JavaScript to agree on something, and that something is the JSON data format.
Nested Arrays in JavaScript, Explained
You asked for it, we delivered. We explain nested arrays in a way that anyone, from beginner to expert, can understand.
How to Declare an Empty Array in JavaScript
Here’s how to declare an empty array object in JavaScript—and what you need to do so that it meets your needs.
Function Not Defined in JavaScript (How to Fix It)
ReferenceErrors are annoying. These common mistakes and clues to look for will help you get to the meat of it.
Alphabet Array in JavaScript (Tutorial)
The simplest, most straightforward ways to create an array of letters in the English alphabet in JavaScript.
Find the Largest Number in an Array in JavaScript
The quick and easy way to find the largest number in an array in JavaScript.
Quotes Within Quotes Within Quotes in JavaScript
There’s a way to nest string in two or more quotes in JavaScript, and you will love the simplicity of it.
Adding a New Line in JavaScript (Tutorial)
Still learning? These are the best ways to add a new line to your JavaScript code’s output.
How to Repeat a String in JavaScript (Tutorial)
In JavaScript, it’s easier to repeat a string an n number of times than you probably think. Here’s how to do it.
Check If an Element Has a Class in JavaScript
So you’re looking for a good way to check if a DOM element has a CSS class in JavaScript?
Check If String Is Empty in JavaScript
Find out the two best ways to check whether a string is empty or not in JavaScript.