vineeth.mariserla

vineeth.mariserla

72 Articles Published

Articles by vineeth.mariserla

Page 5 of 8

Explain in detail about Reference-counting garbage collection in JavaScript?

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

Reference-counting garbage collection is the simplest garbage collection algorithm used in JavaScript. This algorithm monitors objects and removes those that have no references pointing to them. An object becomes eligible for garbage collection when its reference count drops to zero. How Reference-Counting Works The algorithm maintains a count of how many references point to each object. When a reference is created, the count increases. When a reference is removed, the count decreases. Objects with zero references are immediately marked for garbage collection. Example: Basic Reference Counting var obj = { x: ...

Read More

Can re-declaring a variable destroy the value of that variable in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 408 Views

Re-declaring a variable will not destroy the value of that variable, until and unless it is assigned with some other new value. If we look at the following example variables "x" and "y" were assigned with values 4 and 8 respectively, later on when those variables were reassigned, the old values were replaced with the new values and displayed as shown in the output. Example: Re-declaring with New Values var x = new Number(4); ...

Read More

How to pass arrays as function arguments in JavaScript?

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

In JavaScript, you can pass arrays as function arguments using two main approaches: the traditional apply() method and the modern ES6 spread operator (...). The spread operator is now the preferred approach as it provides cleaner, more readable code. Using apply() Method (Traditional) The apply() method was the traditional way to pass array elements as individual arguments to a function. It requires two parameters: the context (this value) and the array of arguments. Syntax functionName.apply(thisContext, arrayOfArguments) Example function displayMarkets(market1, market2, market3) { ...

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

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

How to find the minimum value of an array in JavaScript?

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

JavaScript provides several methods to find the minimum value in an array. The most efficient approach is using Math.min() with the spread operator, though other methods like sorting are also available. Using Math.min() with Spread Operator (Recommended) The Math.min() function finds the smallest number among its arguments. Combined with the spread operator (...), it can easily find the minimum value in an array. Find Minimum function findMinimum() { var numbers = [6, 39, 55, 1, 44]; var minimum = Math.min(...numbers); ...

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 remove html tags from a string in JavaScript?

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

Removing HTML tags from strings is a common task in JavaScript web development. You can accomplish this using regular expressions to match and replace HTML tag patterns with empty strings. Understanding HTML Tag Structure HTML elements are enclosed between angle brackets like , , , etc. By targeting the pattern of content within these brackets, we can effectively strip all HTML tags from a string. Syntax str.replace(/(]+)>)/ig, ''); The regular expression /(]+)>)/ig breaks down as: ]+) - matches one or more characters that aren't closing brackets > - matches closing angle bracket ...

Read More

Describe pass by value and pass by reference in JavaScript?

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

JavaScript passes data to functions in two ways: pass by value for primitives (numbers, strings, booleans) and pass by reference for objects and arrays. Understanding this distinction is crucial for avoiding unexpected behavior in your code. Pass by Value In pass by value, a function receives a copy of the variable's value. Changing this copy inside the function doesn't affect the original variable. JavaScript primitives (numbers, strings, booleans, null, undefined) are always passed by value. Example let a = 1; let change = (val) ...

Read More
Showing 41–50 of 72 articles
« Prev 1 3 4 5 6 7 8 Next »
Advertisements