Programming Articles

Page 885 of 2547

How to send an email from JavaScript?

Rohan Singh
Rohan Singh
Updated on 15-Mar-2026 10K+ Views

Sending emails from JavaScript is a common feature in most web applications. It allows you to automate notifications, send user-generated content, or facilitate communication with your users. We can use different methods like using Mailto protocol, sending emails with a server-side language, and implementing email sending through an API to send emails from JavaScript. In this article, we will explore all of these methods to send email using JavaScript. Basics of Sending Email Before implementing the email-sending feature using different libraries and methods we need to understand what are the basic requirements to send emails. At a high ...

Read More

Sum of all the non-repeating elements of an array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 502 Views

To find the sum of non-repeating elements in an array, we need to identify elements that appear exactly once and add them together. Problem Statement Given an array of numbers, we want to calculate the sum of all elements that appear only once in the array. const arr = [14, 54, 23, 14, 24, 33, 44, 54, 77, 87, 77, 14]; console.log("Input array:", arr); Input array: [14, 54, 23, 14, 24, 33, 44, 54, 77, 87, 77, 14] In this array, the non-repeating elements are: 23, 24, 33, 44, 87. Their ...

Read More

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 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

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

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 781 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

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

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 245 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

what is the main difference between '=' and '==' operators in javascript?

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

In JavaScript, the = operator is used for assignment, while the == operator is used for equality comparison. Understanding this difference is fundamental to writing correct JavaScript code. The Assignment Operator (=) The = operator assigns a value from the right side to the variable on the left side. It does not compare values. var x = 5; // Assigns 5 to variable x var y = "6"; // Assigns string "6" to variable y var z = x; ...

Read More

Explain about logical not(!) operator in detail with example in javascript?

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

The logical NOT operator (!) is a unary operator that inverts boolean values. It returns true for falsy values and false for truthy values. Syntax !expression How It Works The NOT operator first converts the operand to a boolean value, then returns its opposite: If the operand is truthy, it returns false If the operand is falsy, it returns true Example with Boolean Values document.getElementById("boolean-demo").innerHTML = "!true = " + !true ...

Read More

Write a number array and add only odd numbers?

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

In JavaScript, you can sum only the odd numbers from an array by using the modulus operator (%) to check if a number is odd, then adding it to a running total. How It Works The modulus operator returns the remainder when a number is divided by 2. If the remainder is not equal to 0, the number is odd. Example: Summing Odd Numbers var tot = 0; var a = [1, 45, 78, 9, 78, 40, 67, 76]; ...

Read More

How to add an element to a JavaScript object?

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 75K+ Views

In JavaScript, objects are real-time entities that contain properties and methods. Objects store data in key-value pairs, where keys are called properties and values are called property values. There are multiple ways to add new properties to existing JavaScript objects. Let's explore the most common approaches. Object Creation Syntax var obj = new Object(); Or using object literal syntax: var obj = {property1: value1, property2: value2}; Using Dot (.) Operator The dot operator is the most common way to add properties to JavaScript objects. It acts as a connector ...

Read More
Showing 8841–8850 of 25,466 articles
« Prev 1 883 884 885 886 887 2547 Next »
Advertisements