Javascript Articles

Page 61 of 534

How to check if the input date is equal to today's date or not using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 2K+ Views

We learn to check if the input date is equal to today's date or not using JavaScript in this tutorial. Sometimes, we need to take the date from users in the input field in various formats and check if input date and today's date match. Here, we will learn two approaches to check the equality of the input date with today's date. Method 1: Comparing Year, Month, and Date Separately Users can get the full year, month, and date from the timestamp of the Date object using various methods such as getFullYear(), getMonth(), and getDate(). Also, we ...

Read More

How to clone an array in ES6?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 714 Views

In ES6, the spread operator (...) provides the most elegant way to clone arrays. While ES5 used methods like concat() and slice(), ES6 offers a cleaner syntax for array cloning. The Problem with Assignment Operator Using the assignment operator creates a reference, not a copy. This means changes to one array affect the other: Problem with Assignment Operator let output = document.getElementById('output1'); let array1 = ["Hi", "users", "Welcome"]; ...

Read More

How to close a current tab in a browser window using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 8K+ Views

We will learn to close the browser window using JavaScript in this tutorial. Suppose users have opened your website in 2 tabs and don't want to allow it, then you can close one tab automatically using JavaScript. Also, if you have noticed that some web apps automatically open the browser window to capture a face, it closes automatically when you capture the image by clicking the button. It's all we can do using JavaScript. This tutorial will teach different examples of closing the current tab in a browser window using JavaScript. Note − JavaScript never allows developers ...

Read More

How to check whether an array is a subset of another array using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 10K+ Views

The first array is the subset of the second array if the second array contains all elements of the first array. So, sometimes we may be required to check if one array is the subset of another. In this tutorial, we will learn to check if one array is a subset of another array using three different approaches. Using the for loop and array.includes() method Users can use the for loop to iterate through every element of the first array. After that, they can use the includes() method to check if the second array contains every element ...

Read More

How to check whether an object exists in JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 6K+ Views

The object contains the properties and their values in JavaScript. We can create an object using the curly ({}) braces. It's similar to the variables, but we assign an object value rather than assigning the number, string, or boolean value to the variable. So, here we will learn to check if the object exists in JavaScript in this tutorial. In short, we have to learn ways to check the existence of object variables. Using the try-catch Statement Generally, we use the try-catch statement to handle errors in JavaScript. We can try to access the object or its ...

Read More

How to choose a background color through a color picker in JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 4K+ Views

While working with HTML and CSS to create a web page, we require to choose a color from the color picker. Also, sometimes we may require to select the background color through the color picker input. In this tutorial, we will learn different approaches which allow users to choose a background color from the color-picker input, and when the user selects a new color, it should change the background color. Using the Color Picker with Button Click In HTML, color picker input allows users to choose a color from that. We can get a selected color value ...

Read More

How to check two elements are the same using jQuery/JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 2K+ Views

We can access HTML elements using various methods in vanilla JavaScript or jQuery. Sometimes, after accessing DOM elements, developers need to check if both accessed elements are the same or not. In this tutorial, we will learn to use JavaScript's strict equality operator and jQuery's is() method to check the equality of two HTML elements. Using the Equality Operator (===) in JavaScript We can access HTML elements using methods like getElementById, querySelector, getElementsByClassName, etc. After storing elements in JavaScript variables, we can compare them using the strict equality operator (===). Syntax if (element1 === element2) ...

Read More

How to check the OffscreenCanvas is supported by the Browser or not in JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 568 Views

In HTML, Canvas is very important when we want to show animation or 3D objects on the webpage using only HTML and JavaScript. The OffscreenCanvas allows users to render animations and graphics off-screen. It means when we use regular canvas, it interacts with the user via the main thread of the web application, but OffscreenCanvas runs in a separate thread. This improves application performance by preventing graphics rendering from blocking the main UI thread. Before using OffscreenCanvas, we need to check if it's supported by the browser. Otherwise, we should fall back to regular canvas. Let's explore two ...

Read More

Error.prototype.toString() Method in JavaScript

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 2K+ Views

JavaScript's Error.prototype.toString() method is a built-in method that converts error objects to readable string representations. This method is essential for error handling, logging, and debugging in JavaScript applications. Error.prototype.toString() Method The Error.prototype.toString() method converts an error object to a string format. It returns a string containing the error name, followed by a colon and space, then the error message. For example, a standard Error object will produce a string like "Error: something went wrong". Syntax errorObject.toString() Parameters: None Return Value: A string representation of the error object Basic Usage Example Here's ...

Read More

Error: Permission denied to access property 'target' in JavaScript

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 4K+ Views

"Error − Permission denied to access property 'target'" is a common error message that occurs when working with JavaScript, especially when attempting to access the target property of an event object. This error occurs when a script tries to access a property or method of an object that it does not have permission to access. In this tutorial, we will discuss the causes of this error and how to fix it. Understanding the Error The "Error − Permission denied to access property 'target'" is typically caused by the use of the target property of an event object in ...

Read More
Showing 601–610 of 5,340 articles
« Prev 1 59 60 61 62 63 534 Next »
Advertisements