Articles on Trending Technologies

Technical articles with clear explanations and examples

Set Data Structure in Javascript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 583 Views

A Set is a built-in data structure in JavaScript that stores unique values of any type. Unlike arrays, Sets automatically prevent duplicate values and don't maintain insertion order for iteration purposes, making them ideal for storing collections of unique items. Creating a Set You can create a Set using the Set constructor: // Empty Set let emptySet = new Set(); console.log(emptySet); // Set with initial values let numbers = new Set([1, 2, 3, 4, 5]); console.log(numbers); // Set automatically removes duplicates let duplicates = new Set([1, 2, 2, 3, 3, 4]); console.log(duplicates); ...

Read More

Is it possible to change the HTML content in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 2K+ Views

Yes, it is possible to change HTML content using JavaScript. JavaScript provides DOM (Document Object Model) methods that can access and modify HTML elements. These methods, such as document.getElementById(), document.getElementsByTagName(), and others, allow you to dynamically update content in HTML tags like , , , etc. Common Methods to Change HTML Content The most frequently used properties for changing HTML content are: innerHTML - Changes the HTML content inside an element textContent - Changes only the text content (no HTML tags) innerText - Similar to textContent but respects styling Example 1: Changing Content with ...

Read More

JavaScript clearTimeout() & clearInterval() Method

Shriansh Kumar
Shriansh Kumar
Updated on 15-Mar-2026 2K+ Views

In JavaScript, the clearTimeout() and clearInterval() methods are used to clear timers. When we set a timer using setTimeout() or setInterval() methods, the browser allocates memory to track it. Therefore, we use these methods to release that memory and avoid unnecessary function calls. It is best practice to clear timers when they are no longer needed to prevent memory leaks and unwanted executions. JavaScript clearTimeout() Method The clearTimeout() method clears a timeout that was previously set by setTimeout(). It prevents the scheduled function from executing if called before the timeout completes. Syntax clearTimeout(timeoutID) Parameters ...

Read More

How to create a typing effect with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 354 Views

To create a typing effect with JavaScript, you can simulate the appearance of text being typed character by character. This effect is commonly used for animated headers, loading messages, or interactive demonstrations. Basic Typing Effect Here's a complete example that demonstrates how to create a typing effect: body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; padding: 20px; } button { padding: 10px 20px; ...

Read More

Object initializer in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 373 Views

An object initializer is an expression that allows us to initialize a newly created object. It is a comma-separated list of zero or more pairs of property names and associated values of an object, enclosed in a pair of curly braces {}. Basic Syntax const objectName = { property1: value1, property2: value2, // ... more properties }; Simple Object Creation Here's a basic example of creating an object using object initializer syntax: ...

Read More

Insert value in the middle of every value inside array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 427 Views

In JavaScript, you can insert operation objects between array elements to create alternating patterns. This technique is useful for building mathematical expressions or form builders. Problem Statement We have an array of numbers like this: const numbers = [1, 6, 7, 8, 3, 98]; console.log("Original array:", numbers); Original array: [ 1, 6, 7, 8, 3, 98 ] We need to transform this array into objects with "value" keys, and insert operation objects between them using +, -, *, / alternately. Expected Output Structure The final result should look like ...

Read More

How to set current time to some other time in JavaScript?

Daniol Thomas
Daniol Thomas
Updated on 15-Mar-2026 628 Views

You cannot directly modify the system time with JavaScript since it uses the system's clock through the Date object. However, you can simulate different times by adjusting timezones or creating custom date objects with specific values. Method 1: Using Timezone Conversion You can display time for different timezones by calculating the offset from UTC: var date, utc, offset, singaporeTime; date = new Date(); ...

Read More

What is the usage of onpagehide event in JavaScript?

Akshaya Akki
Akshaya Akki
Updated on 15-Mar-2026 521 Views

The onpagehide event triggers in JavaScript when a user leaves the page and navigates away. This occurs during page refresh, clicking links, closing the browser tab, or navigating to another page. Syntax // HTML attribute // JavaScript event listener window.addEventListener('pagehide', function(event) { // Code to execute }); Example: Basic Usage Here's how to implement the onpagehide event using an HTML attribute: Navigate away from this page to see the alert! ...

Read More

How to set height equal to the dynamic width (CSS fluid layout) in JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 732 Views

To set height equal to the dynamic width in JavaScript, you can calculate the element's width and apply it as the height. This creates a perfect square that maintains its aspect ratio as the parent container resizes. Using jQuery jQuery provides a simple way to get and set element dimensions: .wrap { width: 400px; ...

Read More

Backward compatibility with HTML5

Govinda Sai
Govinda Sai
Updated on 15-Mar-2026 1K+ Views

HTML5 is designed to be backward compatible with existing web browsers. New features build on existing features and allow you to provide fallback content for older browsers. Modern browsers like Safari, Chrome, Firefox, and Opera support many HTML5 features. Even older versions of Internet Explorer have partial support, while mobile browsers on iPhones, iPads, and Android phones provide excellent HTML5 compatibility. Feature Detection with JavaScript Instead of browser detection, use feature detection to check if specific HTML5 features are supported: // Check for Canvas support if (document.createElement('canvas').getContext) { console.log('Canvas is ...

Read More
Showing 17851–17860 of 61,297 articles
Advertisements