Latest Posts on Tutorial

Add Remove, Toggle or Replace Class of an Element in JavaScript

Almost all website projects that we work on require us to change the classes of different HTML elements at one time or other. We can do this very easily using jQuery. However, using a library just to change or manipulate the classes of different DOM element is overkill. In this post, we will cover different […]

Replace all Occurrences of a String in JavaScript

JavaScript has a lot of useful methods that you can use to manipulate strings. For example, there is a String.replace() method to replace a simple substring with another string. One problem with this method is that it only replaces the first occurrence of the word or substring. In this tutorial, we will learn about different […]

Remove or Delete a Specific Element from an Array in JavaScript

There are a lot of situations in which you might want to delete or remove a given element from an array. For example, you might be storing the id of different users playing a game in an array and once they are out, you will have to remove the id of that particular player. Similarly, […]

Redirect to Another Webpage in JavaScript

There are many situations where you might want to redirect users to a different page based on some action they took. For example, if the users deleted a post, you might want to redirect them to the homepage after deletion. In this tutorial, you will learn about different methods that can be used to redirect […]

Insert Element(s) at Specific Position in an Array in JavaScript

In one of my previous posts, I mentioned different ways to remove or delete a specific element from an array in JavaScript. When manipulating arrays, the need to insert elements at a specific index is just as common. There are multiple ways to insert elements into an array. Each of these methods has its own […]

Get the Full URL or Query String of Current Page in JavaScript

Every now and then you will want to get the full URL of current page in a project you are working on. Fortunately, JavaScript allows us to get different parts of a URL or the complete URL as a unit. In this post, you will learn about different properties of the Location object returned by […]

Get the Current Timestamp in JavaScript

As a developer, every now and then, you will need to get the current timestamp in JavaScript. It allows us to represent both the current date and time as a single number. There are many ways to get the current timestamp or epoch time or number of seconds since January 1, 1970 00:00:00 UTC. In […]

Get the Current Date and Time in JavaScript

There are a lot of scenarios where you might want to get the current date and time in JavaScript. For instance, you might be creating a website where you want to change the theme based on time of the day like setting a dark theme at night or you might simply want to display the […]

Check if String Contains a Specific Word or Substring in JavaScript

Let’s say you have a string and you want to check if it contains a specific word, character or substring. In this article, you will learn about different ways in which you can perform the check using JavaScript. Here are a few variables that we are going to use: JavaScript var theString = “I have […]

How Can I Check if an Element is Hidden or Visible with JavaScript?

Using JavaScript or jQuery to check if an element is hidden or not sounds very simple. However, there are lot of things that you need can determine the final outcome of such a check. For instance, everyone will have a doing criteria for determine if an element is hidden or visible. In some projects, an […]