Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set whether the text should be overridden to support multiple languages in the same document with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 390 Views

In this tutorial, we will learn how to set whether the text should be overridden to support multiple languages in the same document with JavaScript. Use the unicodeBidi property in JavaScript to set whether the text should be overridden to support multiple languages in the same document. Set it to normal, embed, or bidi-override. The bidi-override allows you to add the direction, i.e., rtl to ltr. Understanding Unicode Bidirectional Text The unicodeBidi property controls the bidirectional text algorithm for elements containing text in multiple languages, especially when mixing left-to-right (LTR) and right-to-left (RTL) scripts like Arabic or ...

Read More

If a DOM Element is removed, are its listeners also removed from memory in javascript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 3K+ Views

In modern browsers, when a DOM element is removed from the document, its event listeners are automatically removed from memory through garbage collection. However, this only happens if the element becomes completely unreferenced. How Garbage Collection Works with DOM Elements Event listeners are automatically cleaned up when: The DOM element is removed from the document No JavaScript variables hold references to the element The element becomes eligible for garbage collection Example: Automatic Cleanup Click Me Remove Button ...

Read More

How to create a curtain navigation menu with CSS and JavaScript?

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 1K+ Views

In this article, we will learn how to create a curtain navigation menu using HTML, CSS and JavaScript. The curtain navigation menu will overlay on the entire screen by pushing back the current page. These menus display the sub-links of a link to make the navigation more specific. To create curtain navigation, we have to do the same as we had done earlier. In curtain navigation, we have two buttons one is an open button (menu) and the other one is a close button (cross). When you click on the open button the navigation will be visible ...

Read More

JavaScript example for Capturing mouse positions after every given interval

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 413 Views

In this article, we will demonstrate how to capture the mouse position in JavaScript at regular intervals and log or use this data for various purposes. Capturing mouse positions after every given interval refers to a program or functionality where the current position of the mouse pointer is tracked at regular time intervals. This can be useful in scenarios like debugging, interactive applications, or visualizing user movement on a web page. Use Cases Imagine you want to monitor user activity on a web page and record the mouse position every second. This can be useful for: ...

Read More

Find number of spaces in a string using JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 3K+ Views

In JavaScript, counting spaces in a string is a common task that can be accomplished using several built-in methods. This article explores different approaches to find the number of space characters in a string. Problem Overview Given a string with space characters, we need to count how many spaces it contains. For example, the string "Hello world example" contains 2 spaces. const exampleString = "This is an example of counting spaces"; // Expected output: 6 spaces Method 1: Using split() Method The split() method divides a string into an array based on a ...

Read More

Return Largest Numbers in Arrays passed using reduce method?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 210 Views

To find the largest number in each array using the reduce() method, combine it with Math.max() and the spread operator. This approach processes multiple arrays and returns an array of maximum values. Syntax array.reduce((accumulator, currentArray) => { accumulator.push(Math.max(...currentArray)); return accumulator; }, []); Example const getBiggestNumberFromArraysPassed = allArrays => allArrays.reduce( (maxValue, maxCurrent) => { maxValue.push(Math.max(...maxCurrent)); return maxValue; }, [] ); console.log(getBiggestNumberFromArraysPassed([[45, ...

Read More

Load a text file and find number of characters in the file - JavaScript

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

Suppose we have a data.txt file that lives in the same directory as our NodeJS file. Suppose the content of that file is − Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s. We are required to write a ...

Read More

Generating n random numbers between a range - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 331 Views

We are required to write a JavaScript function that takes in a number, say n, and an array of two numbers that represents a range. The function should return an array of n random elements all lying between the range provided by the second argument. Understanding the Problem The challenge is to generate unique random numbers within a specified range. We need two helper functions: one to generate a single random number between two values, and another to collect n unique random numbers. Example Implementation Following is the code − const num = 10; ...

Read More

How to handle tabs, line breaks and whitespace in a text in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we will learn how to handle tabs, line breaks, and whitespace in text using JavaScript's CSS white-space property. JavaScript provides control over text formatting through the style.whiteSpace property. This property has several values that determine how whitespace is handled: normal - Default value; collapses multiple spaces into one, wraps text automatically pre - Preserves spaces and tabs, respects line breaks pre-wrap - Like 'pre' but also wraps long lines pre-line - Preserves line breaks but collapses spaces ...

Read More

How do I programmatically create a DragEvent for Angular app and HTML?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 277 Views

Creating a DragEvent programmatically in JavaScript allows you to simulate drag-and-drop operations for testing or automation purposes. There are different approaches depending on whether you're using browser APIs directly or testing frameworks like Protractor. Creating DragEvent with JavaScript API The most direct approach uses the native DragEvent constructor: // Create a new drag event let dragStartEvent = new DragEvent('dragstart', { bubbles: true, cancelable: true, dataTransfer: new DataTransfer() }); // Get target element let element = document.getElementById('draggable-item'); // Dispatch the event element.dispatchEvent(dragStartEvent); ...

Read More
Showing 16811–16820 of 61,297 articles
Advertisements