Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set the space between characters in a text with JavaScript?

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

To set the space between characters in text, use the JavaScript letterSpacing property. This property controls the horizontal spacing between individual characters in a text element. Syntax element.style.letterSpacing = "value"; The value can be specified in pixels (px), em units, or other CSS length units. Negative values decrease spacing, while positive values increase it. Example: Setting Letter Spacing Here's a complete example that demonstrates how to set character spacing with JavaScript: Letter Spacing Example ...

Read More

Alternatives to HTML5 iframe srcdoc?

George John
George John
Updated on 15-Mar-2026 657 Views

The HTML tag is used to create an inline frame. While the srcdoc attribute allows embedding HTML content directly, several alternatives exist for dynamically setting iframe content. Understanding iframe srcdoc The srcdoc attribute specifies HTML content to display inside an iframe without requiring an external URL. iframe srcdoc Example Alternative 1: Using contentWindow.document Access the iframe's document object directly to write content programmatically. contentWindow Alternative ...

Read More

Subtract two Sets in Javascript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 3K+ Views

Set subtraction (difference) removes all elements from the first set that exist in the second set. JavaScript doesn't provide a built-in difference method, but we can create one using forEach or modern Set methods. Using forEach Method We can create a static method to subtract one Set from another: Set.difference = function(s1, s2) { if (!(s1 instanceof Set) || !(s2 instanceof Set)) { console.log("The given objects are not of type Set"); return null; ...

Read More

What is non-enumerable property in JavaScript and how can it be created?

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

Objects can have properties that don't show up when iterated through the particular object using Object.keys() or for...in loop. Those type of properties are called as non-enumerable properties. What are Non-enumerable Properties? Non-enumerable properties are object properties that are hidden from enumeration methods like Object.keys(), for...in loops, and Object.entries(). However, they can still be accessed directly using their property name. Creating Non-enumerable Properties To create a non-enumerable property we have to use Object.defineProperty() method. This is a special method to create non-enumerable properties in an object. Syntax Object.defineProperty(object, propertyName, { ...

Read More

What is global namespace pollution in JavaScript?

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

Global namespace pollution occurs when too many variables and functions are declared in the global scope, leading to name collisions. This is especially problematic in large projects using multiple JavaScript libraries. What is Name Collision? Name collision happens when two or more scripts define variables or functions with the same name in the global scope. The last definition overwrites previous ones, causing unexpected behavior. Example: Two Teams, Same Function Name Let's demonstrate with two JavaScript files from different teams: TeamA1.js Team A1 creates a student constructor with 2 parameters: function student(fname, lname) ...

Read More

How to allocate memory in Javascript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 612 Views

Regardless of the programming language, memory life cycle is pretty much always the same: Allocate the memory you need Use the allocated memory (read, write) Release the allocated memory when it is not needed anymore The second part is explicit in all languages. Use of allocated memory needs to be done by the developer. The first and last parts are explicit in low-level languages like C but are mostly implicit in high-level languages like JavaScript. Hence there is no explicit way to allocate or free up memory in JavaScript. Just initializing objects allocates memory ...

Read More

JavaScript encodeURI(), decodeURI() and its components functions

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 386 Views

JavaScript provides four essential functions for handling URI encoding and decoding. The encodeURI() function encodes complete URIs while preserving structural characters, whereas encodeURIComponent() encodes URI components including all special characters. Understanding the Functions The encodeURI() function encodes special characters in a URI except for reserved characters like , / ? : @ & = + $ # which are essential for URI structure. The encodeURIComponent() function encodes URI components by encoding all special characters including the reserved ones. The corresponding decode functions decodeURI() and decodeURIComponent() reverse the encoding process. Syntax encodeURI(uri) decodeURI(encodedURI) encodeURIComponent(uriComponent) decodeURIComponent(encodedURIComponent) ...

Read More

How to close list items with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 658 Views

Closing list items with JavaScript involves adding click event listeners to close buttons that hide or remove list items from the DOM. This creates an interactive list where users can dismiss items they no longer need. Complete Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } * { ...

Read More

How to output JavaScript into a Textbox?

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

You can output JavaScript values to a textbox using the value property. This is commonly done to display calculation results or user feedback. Basic Approach To output to a textbox, access the input element and set its value property: document.getElementById("myTextbox").value = "Your output here"; Example: Calculator with Textbox Output JavaScript Textbox Output First Number: ...

Read More

Product of all other numbers an array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 395 Views

Let's say, we have to write a function that takes an array of numbers as argument. We have to return a new array with the products of each number except the index we are currently calculating product for. For example, if arr had 5 indices and we were creating the value for index 1, the numbers at index 0, 2, 3 and 4 would be multiplied. Similarly, if we were creating the value for index 2, the numbers at index 0, 1, 3 and 4 would be multiplied and so on. Note − It is guaranteed that all ...

Read More
Showing 17921–17930 of 61,297 articles
Advertisements