Articles on Trending Technologies

Technical articles with clear explanations and examples

How to clear a chart from HTML5 canvas so that hover events cannot be triggered?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 317 Views

To completely clear a chart from an HTML5 canvas and ensure hover events are no longer triggered, the most effective approach is to remove the canvas element and create a new one. This method guarantees all event listeners and chart data are cleared. Method 1: Remove and Recreate Canvas Element This approach removes the existing canvas and creates a fresh one, eliminating all associated event listeners and chart data. var resetCanvas = function(){ // Remove the existing canvas $('#results-graph').remove(); ...

Read More

How to display the domain of the server that loaded a document in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 589 Views

In this following article we are going to learn how to display the domain of the server that loaded a document in JavaScript. To display the domain of the server, we use domain property of the document interface, which returns the domain part of the current document. The domain property will return NULL if the document was created in memory. Attempting to set the domain property of the document interface results in SecurityError. To understand better, let's look into the syntax and usage of domain property with suitable examples in JavaScript. Using document.domain Property We can ...

Read More

Explain import "as" and Export "as" constructs in JavaScript.

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 263 Views

Import as and export as constructs allow you to rename modules during import/export operations, providing flexibility and avoiding naming conflicts in JavaScript. What is Import "as"? The import as syntax allows you to import a named export under a different name in the importing module. This is useful when you want to avoid naming conflicts or use more descriptive names. What is Export "as"? The export as syntax allows you to export a function or variable under a different name than its original declaration. This gives you control over how your module's API is exposed. ...

Read More

map() array of object titles into a new array based on other property value JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 287 Views

Let's say, we have an array of objects like this − const arr = [{ country: "canada", count: 2 }, { country: "jamaica", count: 2 }, { country: "russia", count: 1 }, { country: "india", count: 3 }, { country: "spain", count: 2 }, { country: "portugal", count: 1 }, ...

Read More

Fetch Second minimum element from an array without sorting JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 547 Views

We have an array of Numbers, and we are required to write a function that returns the second smallest value from the array. For example − if the array is − const arr = [67, 87, 56, 8, 56, 78, 54, 67, 98, 56, 54]; Then the output should be the following − 54 because 54 is the smallest value after 8 Method 1: Using indexOf and splice This approach finds the minimum element, removes it from a copy of the array, then finds the minimum of the remaining ...

Read More

Find closest index of array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

When working with arrays in JavaScript, you might need to find the index of the element that is numerically closest to a given target value. This is useful in scenarios like finding the nearest data point, closest price match, or similar proximity-based searches. Problem Statement Given an array of numbers and a target value, we need to find the index of the array element that has the smallest absolute difference from the target. const arr = [2, 42, 82, 122, 162, 202, 242, 282, 322, 362]; For example, if our target is 150, we ...

Read More

How to do basic form validation using JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 824 Views

JavaScript provides a way to validate form data on the client's computer before sending it to the web server. This improves user experience by catching errors immediately and reduces server load. Basic form validation includes checking that all mandatory fields are filled in and that data meets specific format requirements. It requires looping through each field in the form and validating the data. Basic Validation Methods Form validation typically checks for: Empty required fields Data format (email, phone, zip code) Data length constraints ...

Read More

What is the role of special characters in JavaScript Regular Expressions?

V Jyothi
V Jyothi
Updated on 15-Mar-2026 336 Views

Special characters in JavaScript regular expressions are metacharacters that define patterns for matching text. These characters control how many times a character or group should appear and where it should be positioned within a string. Quantifiers Quantifiers specify how many times the preceding character or group should match: Character Description + Matches one or more occurrences of the preceding character * Matches zero or more occurrences of the preceding character ? Matches zero or one occurrence of the preceding character {n} Matches exactly n ...

Read More

How to draw grid using HTML5 and canvas or SVG?

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 748 Views

HTML5 provides two powerful ways to create grid patterns: Canvas and SVG. Both offer different advantages depending on your needs. Drawing Grid Using HTML5 Canvas Canvas provides a pixel-based approach for drawing grids programmatically. Here's how to create a basic grid: // Get canvas and context const canvas = document.getElementById('gridCanvas'); const ctx = canvas.getContext('2d'); // Grid settings const gridSize = 20; // Size of each grid cell const canvasWidth = canvas.width; const canvasHeight = canvas.height; // Set line style ctx.strokeStyle = '#ddd'; ctx.lineWidth = 1; // Draw vertical lines for (let x = 0; x

Read More

Type Selectors in CSS

varma
varma
Updated on 15-Mar-2026 1K+ Views

Type selectors in CSS target HTML elements directly by their tag names. They are the most basic form of CSS selectors and apply styles to all instances of a specific HTML element throughout the document. Syntax element { property: value; } Where element is any valid HTML tag name like h1, p, div, span, etc. Example: Styling Headings h1 { ...

Read More
Showing 18441–18450 of 61,297 articles
Advertisements