Web Development Articles

Page 145 of 801

How to Deep Merge Two Objects in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 15-Mar-2026 1K+ Views

In JavaScript, a deep merge of two objects means creating a new object by combining properties recursively, including nested objects. Unlike a simple merge, it ensures that no nested properties are lost during the merge, which only replaces top-level properties. In this article, we will look at several ways of performing a deep merge of two objects, with code and explanations. Approaches to Deep Merge Manual Recursive Function Using Lodash's merge Method Using the Spread Operator with Recursion Using Object.assign with Recursion ...

Read More

JavaScript Program for Searching an Element in a Linked List

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 679 Views

To search for an element in a linked list, we need to go through each node one by one and check if its value matches the target element. If we find the element, we return its position in the list. If not, we return a message saying the element is not found. In this article, our task is to implement a JavaScript program that searches for a specific element in a linked list and returns its position if found, or a message if it is not present. Example Let's look at the below examples: Linked ...

Read More

JavaScript Program for Left Rotation and Right Rotation of a String

Shriansh Kumar
Shriansh Kumar
Updated on 15-Mar-2026 1K+ Views

To implement left rotation and right rotation of a string, we can use various approaches. Left rotation means moving characters counter-clockwise by a given number of positions, while right rotation means moving characters clockwise by a given number of positions. In this article we have a string and a value of k by which we will rotate the string. Our task is to write a JavaScript program for left rotation and right rotation of a string. Example Input: String str = "apple"; k = 3 Output: Left Rotation: "leapp" Right Rotation: "pleap" Approaches ...

Read More

JavaScript program to generate all rotations of a number

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 729 Views

In this article, we will learn to generate all rotations of a number in JavaScript. A rotation involves moving the first digit to the end of the number, creating all possible circular arrangements of the digits. Problem Statement Given a number, we need to generate all possible rotations of its digits. A rotation is defined as moving the first digit to the end of the number. Input: 123 All Rotations: 123 (original number) 231 (first rotation: move 1 to the end) 312 (second ...

Read More

JavaScript program to count triplets with sum smaller than a given value

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 565 Views

In this article, we will learn to count triplets with a sum smaller than a given value in JavaScript. Triplets in an array whose sum is less than a provided number is a popular problem in competitive coding and algorithm design. Problem Statement Given an array of integers and a target sum, we need to find the number of triplets (a, b, c) where the sum of three elements is less than the given value. Input: const arr = [5, 1, 3, 4, 7]; const sum = 12; Output: 4 ...

Read More

JavaScript Program to Find Perimeter of a Triangle

Disha Verma
Disha Verma
Updated on 15-Mar-2026 1K+ Views

The perimeter of a triangle is the sum of the lengths of its three sides. You can find the perimeter of a triangle using JavaScript by calculating the sum of all sides, where perimeter = a + b + c. To find the perimeter of a triangle using JavaScript, we need to write a function that adds the three side lengths together. In this article, we will understand the perimeter formula and implement practical examples. Understanding the Perimeter Formula The formula for the perimeter of a triangle is straightforward. The perimeter equals the sum of all three ...

Read More

JavaScript Program to Find Area and Perimeter of Rectangle

Disha Verma
Disha Verma
Updated on 15-Mar-2026 9K+ Views

To find the area and perimeter of a rectangle in JavaScript, we use the basic formulas for rectangle calculations. The area of a rectangle is the multiplication of its length by its breadth, and the perimeter is the sum of all four sides. In this article, we'll understand the formulas and implement practical JavaScript examples to calculate rectangle area and perimeter. Understanding the Formulas The formulas for rectangle calculations are straightforward: Area = length × breadth Perimeter = 2 × (length + breadth) ...

Read More

JavaScript Program to Find the Lost Element from a Duplicated Array

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 1K+ Views

To find the lost element from a duplicated array in JavaScript, we will be discussing various approaches. Prerequisites to solve this problem include understanding of JavaScript arrays, loops, Set object, and binary search. In this article we have two arrays where one array is a duplicate of the other with one missing element. Our task is to find the lost element from the duplicated array in JavaScript. Problem Statement Given two arrays where the second array is missing exactly one element from the first array, we need to identify that missing element. Input: array1 = ...

Read More

JavaScript Program for Counting Frequencies of Array Elements

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 2K+ Views

Counting frequencies of array elements means determining how many times each element appears in an array. This is a common programming task useful for data analysis, statistics, and various algorithms. JavaScript provides multiple approaches to solve this problem efficiently. In this article, we'll explore five different methods to count element frequencies in JavaScript. Each approach has its own advantages - some prioritize simplicity, others performance, and some leverage built-in methods or external libraries. Approaches to Count Array Elements Frequencies Here are the five approaches we'll cover, each with detailed explanations and complete working examples: ...

Read More

JavaScript Program to Find Lexicographically minimum string rotation

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 722 Views

To find lexicographically minimum string rotation in JavaScript, we will understand two different approaches in this article. A lexicographically minimum rotation of a string is the smallest string that can be obtained by rotating the original string any number of times in lexicographical order. By lexicographical order it means dictionary order such as: a < b, ab < ac. In this article we are having a string. Our task is to write a JavaScript program to find lexicographically minimum string rotation. Example Input: bba All lexicographical order are: bba, bab, abb Output: Smallest lexicographical ...

Read More
Showing 1441–1450 of 8,010 articles
« Prev 1 143 144 145 146 147 801 Next »
Advertisements