Articles on Trending Technologies

Technical articles with clear explanations and examples

How objects are organized in a web document? How is it arranged in a hierarchy?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 294 Views

The objects in a web document are organized in a hierarchical structure called the Document Object Model (DOM). This hierarchy represents the relationship between different elements and allows JavaScript to interact with web page components systematically. DOM Hierarchy Structure The DOM follows a tree-like structure where each object has a specific position and relationship with other objects: Window object − Top of the hierarchy. It represents the browser window and is the global object for all JavaScript operations. ...

Read More

Zoom HTML5 Canvas to Mouse Cursor

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 1K+ Views

The HTML5 Canvas API provides powerful methods to zoom content toward a specific point, such as the mouse cursor. By default, the canvas scales from its origin at [0, 0], but you can change this behavior using coordinate transformations. Understanding Canvas Transformations The translate() method moves the canvas origin to a new position, while scale() resizes the drawing context. To zoom toward the mouse cursor, you need to combine these transformations in a specific sequence. The Zoom Algorithm To zoom toward a specific point (like mouse coordinates), follow these three steps: ctx.translate(pt.x, pt.y); ...

Read More

Difference between specification and recommendation that introduced CSS

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

CSS development follows a formal process where specifications evolve into recommendations through the World Wide Web Consortium (W3C). Understanding this difference helps explain how web standards are created and adopted. What is a CSS Specification? A CSS specification is a working document created by the CSS Working Group that describes new features, properties, or modules for CSS. These are draft documents that undergo continuous review, discussion, and revision. Specifications go through several stages: Working Draft (WD) - Initial public version Candidate Recommendation (CR) - Feature-complete and ready for implementation Proposed Recommendation (PR) - Final review stage ...

Read More

How to detect whether the browser is online or offline with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 490 Views

JavaScript provides the navigator.onLine property to detect whether the browser is online or offline. This property returns true when connected to the internet and false when offline. The navigator.onLine Property The navigator.onLine property is a read-only boolean that indicates the browser's online status: // Basic syntax if (navigator.onLine) { // Browser is online } else { // Browser is offline } Example: Manual Check Online/Offline Status Checker Check Status ...

Read More

What are Partial functions in JavaScript?

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

Partial functions in JavaScript allow you to create specialized versions of functions by pre-filling some of their arguments. They take a function and some arguments, returning a new function that remembers those arguments and waits for the remaining ones. This technique is useful for creating reusable function variants and implementing functional programming patterns like currying. Basic Partial Function Example Partial Functions Partial Functions in JavaScript ...

Read More

Construct string via recursion JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 387 Views

We are required to write a recursive function, say pickString that takes in a string that contains a combination of alphabets and numbers and returns a new string consisting of only alphabets. For example, If the string is 'dis122344as65t34er', The output will be: 'disaster' Therefore, let's write the code for this recursive function − Syntax const pickString = (str, len = 0, res = '') => { if(len < str.length){ const char = parseInt(str[len], 10) ? '' : str[len]; ...

Read More

Shift last given number of elements to front of array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 308 Views

In JavaScript, moving elements from the end of an array to the front is a common array manipulation task. This tutorial shows how to create a function that shifts the last n elements to the beginning of an array in-place. Problem Statement We need to create an array method reshuffle() that: Takes a number n (where n ≤ array length) Moves the last n elements to the front Modifies the array in-place Returns true on success, false if n exceeds array length Example Input and Output // Original array const arr = ["blue", ...

Read More

Checking for co-prime numbers - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 526 Views

Two numbers are said to be co-primes if there exists no common prime factor amongst them (1 is not a prime number). For example: 4 and 5 are co-primes 9 and 14 are co-primes 18 and 35 are co-primes 21 and 57 are not co-prime because they have 3 as the common prime factor We are required to write a function that takes in two numbers and returns true if they are co-primes otherwise returns false. Understanding Co-prime Numbers Two numbers are co-prime if their greatest common divisor (GCD) is 1. This means ...

Read More

How can I set the default value for an HTML \'select\' element?

usharani
usharani
Updated on 15-Mar-2026 907 Views

To set the default value for an HTML element, we can use the HTML selected attribute. This attribute allows you to display a predefined option when the dropdown menu first loads. In this article, we'll explore different approaches to set default values for HTML select elements with practical examples. Using the selected Attribute The most common method is adding the selected attribute to the desired element: Default Select Value Select Your Course ...

Read More

What are the document methods supported by Legacy DOM?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 183 Views

The Legacy DOM provided several document methods for manipulating document content. While most are deprecated in modern web development, understanding them helps with legacy code maintenance. Legacy DOM Document Methods Method Description & Usage clear() Deprecated - Erased document contents and returned nothing. Example: document.clear() close() Closes a document stream opened with open() method. Example: document.close() open() Deletes existing content and opens a stream for new content. Example: document.open() write() Inserts strings into the document during parsing or after open(). Example: document.write("Hello World") ...

Read More
Showing 18421–18430 of 61,297 articles
Advertisements