vineeth.mariserla

vineeth.mariserla

72 Articles Published

Articles by vineeth.mariserla

72 articles

How to Title Case a sentence in JavaScript?

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

Title case formatting converts the first letter of each word in a sentence to uppercase while keeping the remaining letters lowercase. This is commonly used for headings, titles, and proper formatting of text. Algorithm Split the sentence into individual words using string.split() method Convert all letters in each word to lowercase using string.toLowerCase() method Loop through each word and capitalize the first letter using toUpperCase() Concatenate the capitalized first letter with the remaining lowercase letters Join all words ...

Read More

How to parse an URL in JavaScript?

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

JavaScript provides several methods to parse URLs and extract their components like protocol, hostname, pathname, and query parameters. The modern approach uses the built-in URL constructor, while legacy methods involve creating DOM anchor elements. Using the URL Constructor (Modern Approach) The URL constructor is the standard way to parse URLs in modern JavaScript. It creates a URL object with all components easily accessible. const url = new URL("https://www.youtube.com/watch?v=tNJJSrfKYwQ"); console.log("Protocol:", url.protocol); console.log("Host:", url.host); ...

Read More

How to add two strings with a space in first string in JavaScript?

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

To concatenate two strings in JavaScript, we use the '+' operator. When the first string already contains a trailing space, we can directly concatenate without adding an explicit space. However, if there's no space, we need to add one manually between the strings. Method 1: First String Has Trailing Space When the first string already ends with a space, simple concatenation is sufficient: function concatenateStrings(str1, str2) { return (str1 ...

Read More

What is the use of Object.is() method in JavaScript?

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

The Object.is() method determines whether two values are strictly equal, providing more precise comparison than the regular equality operators. Syntax Object.is(value1, value2) Parameters value1: The first value to compare value2: The second value to compare Return Value Returns true if both values are the same, false otherwise. How Object.is() Determines Equality Two values are considered the same when they meet these criteria: Both are undefined or both are null Both are true or both ...

Read More

What is the importance of _.union() method in JavaScript?

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

The _.union() method from the Underscore.js library creates a new array containing unique values from multiple input arrays. It performs a union operation, removing duplicates while preserving the original order of first occurrence. Syntax _.union(array1, array2, ...arrayN); Parameters array1, array2, ...arrayN: Two or more arrays to be combined. The method accepts any number of arrays as arguments. Return Value Returns a new array containing all unique values from the input arrays, maintaining the order of first occurrence. Example with Numbers In the following example, _.union() combines multiple arrays and removes ...

Read More

How can Detached DOM elements cause memory leak in JavaScript?

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

Detached DOM elements are nodes that have been removed from the DOM tree but still exist in memory because JavaScript variables maintain references to them. This prevents the garbage collector from freeing the memory, leading to memory leaks. Understanding DOM Tree Structure The DOM is a double-linked tree structure where each node holds references to its parent and children. When you maintain a JavaScript reference to any node, the entire subtree remains in memory even after removal from the visible DOM. DOM Tree ...

Read More

What is the use of ()(parenthesis) brackets in accessing a function in JavaScript?

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

The parentheses () are crucial for function invocation in JavaScript. Accessing a function without parentheses returns the function reference, while using parentheses calls the function and returns its result. Function Reference vs Function Call When you write a function name without parentheses, JavaScript treats it as a reference to the function object. With parentheses, JavaScript executes the function. Without Parentheses - Function Reference Accessing a function without parentheses returns the function definition itself, not the result: function toCelsius(f) { return (5/9) * ...

Read More

How can Forgotten timers or callbacks cause memory leaks in JavaScript?

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

JavaScript memory leaks commonly occur when timers and callbacks maintain references to objects that should be garbage collected. Understanding these patterns helps prevent memory issues in web applications. How Timers Create Memory Leaks When objects are referenced inside timer callbacks, the garbage collector cannot release them until the timer completes. If timers run indefinitely or reset themselves, the referenced objects remain in memory permanently. Timer Functions Overview JavaScript provides two main timing functions: setTimeout() - Executes a function once after a specified delay setInterval() - Executes a function repeatedly at specified intervals ...

Read More

In how many ways can we find a substring inside a string in javascript?

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

JavaScript provides several methods to find a substring inside a string. The most commonly used approaches are indexOf(), includes(), search(), and regular expressions with match(). Using indexOf() Method Syntax string.indexOf(substring, startPosition) The indexOf() method returns the index of the first occurrence of the substring. If the substring is not found, it returns -1. This method is case-sensitive. Example var company = "Tutorialspoint"; document.write("Index of 'point': " + company.indexOf('point')); document.write(""); document.write("Is 'Tutor' present: " + (company.indexOf('Tutor') !== ...

Read More

Write the main difference between '==' and '===' operators in javascript?

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

The main difference between == and === operators in JavaScript is that == performs type coercion (converts types before comparing), while === performs strict comparison without any type conversion. The == Operator (Loose Equality) The == operator compares values after converting them to the same type if needed. This can lead to unexpected results. Example var x = 5; var y = "5"; var z = 6; document.getElementById("loose").innerHTML = (x == y) + "" + (x == z); Output true false Notice ...

Read More
Showing 1–10 of 72 articles
« Prev 1 2 3 4 5 8 Next »
Advertisements