Front End Technology Articles

Page 315 of 652

Get value for key from nested JSON object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 18K+ Views

In JavaScript, accessing values from nested JSON objects is a common task when working with APIs and complex data structures. We can retrieve nested values using dot notation, bracket notation, or custom functions. Before exploring different approaches, let's understand what JSON and nested JSON objects are: What is JSON and Nested JSON Objects? JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data. It's widely used for data transmission between web applications and servers. Nested JSON objects contain objects within other objects, creating a hierarchical structure. Each nested property has a unique path ...

Read More

Group matching element in array in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 405 Views

In JavaScript, grouping matching elements in an array is a common task that can be efficiently solved using the reduce() method. This approach allows us to iterate through an array and group consecutive duplicate elements together. What is the reduce() Function? The reduce() method is a built-in JavaScript function that processes each element of an array and accumulates a result. It takes a callback function with two main parameters: an accumulator (which stores the accumulated result) and the current value being processed. Basic reduce() Example const numbers = [1, 2, 3, 4, 5]; const sum ...

Read More

How to implement backtracking for a climbing stairs practice in JavaScript?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 443 Views

In the given problem statement we are asked to implement backtracking for a climbing stairs practice with the help of JavaScript functionalities. In data structures, backtracking is popularly known to explore all possible solutions. We can solve this problem with the help of a backtracking algorithm. What is the Backtracking Technique? Backtracking is a well-known algorithmic technique, which is basically used to solve problem statements that include searching for all possible solutions. It is based on a depth-first strategy and is used in combination with a recursive method. The basic ideology for this technique is to explore ...

Read More

Sorting an array including the elements present in the subarrays in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 310 Views

In JavaScript, we often encounter arrays that contain nested subarrays and need to sort all elements together. This involves flattening the nested structure and then applying sorting algorithms. Understanding the Required Methods Before diving into solutions, let's understand the key JavaScript methods we'll use: sort() method: Sorts array elements in place. By default, it converts elements to strings and sorts alphabetically. For numeric sorting, we provide a comparison function: let numbers = [3, 1, 4, 1, 5, 9, 2, 6]; numbers.sort((a, b) => a - b); // ascending order console.log(numbers); [ 1, ...

Read More

Using BigInt to calculate long factorials in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 2K+ Views

In JavaScript, calculating factorials of large numbers requires the BigInt data type to avoid precision loss. BigInt handles arbitrarily large integers, making it perfect for computing long factorials that exceed JavaScript's standard number limits. What is BigInt? BigInt is a built-in JavaScript data type introduced in ECMAScript 2020 that represents integers of arbitrary size. Unlike the standard Number type, which has a maximum safe integer limit of 2^53 - 1, BigInt can handle infinitely large integers. // Regular numbers have limits console.log(Number.MAX_SAFE_INTEGER); // 9007199254740991 // BigInt can handle much larger values console.log(BigInt(Number.MAX_SAFE_INTEGER) * 100n); ...

Read More

Merging subarrays in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 670 Views

This problem demonstrates how to merge subarrays containing email data by grouping emails under the same person's name. We'll use JavaScript's Set data structure to eliminate duplicates and organize the data efficiently. Understanding the Problem Given an array of subarrays where each subarray contains a person's name followed by their email addresses, we need to merge all emails belonging to the same person into a single subarray. For example, if "Ayaan" appears in multiple subarrays with different emails, we should combine all of Ayaan's emails into one subarray. Algorithm Step 1 − Create a function that ...

Read More

What is the best way to search for an item in a sorted list in JavaScript?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 591 Views

When searching for an item in a sorted array in JavaScript, binary search is the most efficient approach. Unlike linear search which checks every element, binary search takes advantage of the sorted order to eliminate half the search space with each comparison. What is Binary Search? Binary search is a divide-and-conquer algorithm that works on sorted arrays. It compares the target value with the middle element and eliminates half of the remaining elements at each step. This approach has O(log n) time complexity, making it much faster than linear search's O(n). How Binary Search Works The ...

Read More

JSON group object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 884 Views

In JavaScript, grouping JSON objects means organizing data by common properties or categories. This is useful for data analysis, filtering, and creating structured reports from collections of objects. What is JSON? JSON (JavaScript Object Notation) is a lightweight data format for transferring data between devices. JSON objects use key-value pairs where keys are strings and values can be strings, numbers, booleans, arrays, or nested objects. For example: {"name": "Alice", "age": 25}. const jsonData = [ { team: 'TeamA', score: 20 }, { ...

Read More

Make an array of another array\'s duplicate values in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 1K+ Views

In JavaScript, finding duplicate values between two arrays is a common task. This article demonstrates how to create an array containing elements that exist in both arrays using built-in array methods. What is an Array in JavaScript? An array is an object that stores multiple elements in a single variable. Arrays in JavaScript are ordered collections that can hold any data type and provide methods like filter() and indexOf() for manipulation. const array = [201, 202, 405]; Understanding the Logic To find duplicate values between two arrays, we use the filter() method on ...

Read More

Manipulate Object to group based on Array Object List in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 354 Views

Grouping objects in JavaScript is a common operation when working with arrays of objects. This technique allows you to organize data by specific properties, making it easier to process and analyze related items together. Understanding the Problem Consider an array of objects representing people with properties like name, profession, and age. We want to group these objects by a specific property (like profession) to create an organized structure where each group contains all objects sharing that property value. For example, grouping people by profession would create separate arrays for developers, teachers, engineers, etc. This organization makes it ...

Read More
Showing 3141–3150 of 6,519 articles
« Prev 1 313 314 315 316 317 652 Next »
Advertisements