Articles on Trending Technologies

Technical articles with clear explanations and examples

Is their JavaScript scroll event for iPhone/iPad?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 443 Views

Yes, iOS Safari captures scroll events on iPhone and iPad. However, iOS handles scrolling differently than desktop browsers, using momentum scrolling and gesture-based interactions. Basic Scroll Event Detection You can use the standard scroll event listener on iOS devices: Scroll this content on mobile... Content line 2 Content line 3 Content line 4 Content line 5 Scroll position: 0 const scrollable = document.getElementById('scrollable'); const output = ...

Read More

cache.manifest works for the first time then fails in HTML

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 130 Views

HTML5 Application Cache (cache.manifest) can fail after the first load due to caching issues. Here are solutions to ensure proper cache updates. Add NETWORK Section Add the NETWORK section at the bottom of your manifest file to allow network access for unlisted resources: CACHE MANIFEST CACHE: /css/style.css /js/myscript.js /images/logo.png NETWORK: * Version Your Manifest File Include a version parameter in the manifest attribute to force cache updates when content changes: My App Cached Application ...

Read More

Circular linked lists in Javascript

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

A Circular Linked List is a variation of the standard linked list where the first element points to the last element and the last element points back to the first element, forming a circle. Both singly and doubly linked lists can be implemented as circular structures. Data: 10 Data: 20 Data: 30 ...

Read More

How can closures cause memory leak and how to prevent it?

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

Closures are one of JavaScript's powerful features, allowing inner functions to access variables from their outer (parent) functions. However, this can sometimes lead to memory leaks when variables remain in memory longer than necessary. Understanding Closure Memory Leaks A memory leak occurs when variables from outer functions remain accessible to inner functions, preventing garbage collection even when those variables aren't actively used. The JavaScript engine keeps these variables in memory because the inner function might reference them. Example of Potential Memory Leak function parentFunction(arg1) { ...

Read More

JavaScript Auto-filling one field same as other

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 431 Views

Auto-filling form fields is a common requirement in web forms, especially when users need to copy address information between billing and shipping sections. This can be achieved using JavaScript event listeners and form field manipulation. Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; padding: 20px; } ...

Read More

loose equality in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 313 Views

The loose equality operator == compares two values after performing type coercion, converting them to a common type before comparison. This differs from strict equality (===) which compares both value and type. Syntax operand1 == operand2 How Loose Equality Works When using ==, JavaScript follows specific conversion rules: If types are the same, compare values directly If one is a number and the other a string, convert string to number If one is boolean, convert to number first null and undefined are equal to each other Example ...

Read More

JavaScript remove random item from array and then remove it from array until array is empty

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 3K+ Views

We are given an array of string/number literals. We are required to create a function removeRandom() that takes in the array, recursively removes one random item from it, and simultaneously prints it until the array contains items. This can be done by creating a random number using Math.random(), removing the item at that index using Array.prototype.splice(), and printing it until the length of the array shrinks to 0. Approaches to Remove Random Items from Array Following are the different approaches to removing the random item from an array and then removing it from the array until the ...

Read More

Create a Calculator function in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 918 Views

We have to write a function, say calculator() that takes in one of the four characters (+, - , *, / ) as the first argument and any number of Number literals after that. Our job is to perform the operation specified as the first argument over those numbers and return the result. If the operation is multiplication or addition, we are required to perform the same operation with every element. But if the operation is subtraction or division, we have to consider the first element as neutral and subtract all other elements from it or divide it by ...

Read More

Regex - reusing patterns to capture groups in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 596 Views

Regular expressions can use backreferences to capture groups and reuse them later in the pattern. The syntax \1, \2, etc., refers to previously captured groups. How Backreferences Work When you create a group with parentheses (), the regex engine remembers the matched content. You can reference this captured content later using \1 for the first group, \2 for the second, and so on. Syntax /^(pattern1)(pattern2)\1\2$/ // \1 matches the same text as the first group // \2 matches the same text as the second group Example: Matching Repeated Patterns var groupValues1 ...

Read More

Random name generator function in JavaScript

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

We are required to write a JavaScript function that takes in a number n and returns a random string of length n containing no other than the 26 English lowercase alphabets. Example Let us write the code for this function: const num = 8; const randomNameGenerator = num => { let res = ''; for(let i = 0; i < num; i++){ const random = Math.floor(Math.random() * 26); res += String.fromCharCode(97 + ...

Read More
Showing 17811–17820 of 61,297 articles
Advertisements