Articles on Trending Technologies

Technical articles with clear explanations and examples

Picking the largest elements from multidimensional array in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 3K+ Views

Given a multidimensional array, we need to pick the largest elements from each subarray in JavaScript. The multidimensional arrays are arrays inside an array. Whenever there are arrays inside the array, it works as a multidimensional array. Following is a one-dimensional array: const arr = ["Welcome", "to", "tutorials", "point"]; const numbers = [1, 5, 12, 67, 99]; This is how a multidimensional array looks like: const array = [["Mike tyson", "Vijay"], ["ananya", "charmee"], ["Lion", "Tiger"]]; This is how we can access elements from a multidimensional array: ...

Read More

Two sum in BSTs in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 302 Views

We are required to write a JavaScript function that takes in the roots of two binary search trees, root1 and root2, as the first and the second argument respectively. The third argument to the function is number, target. Our function should return True if and only if there is a node in the first tree and a node in the second tree whose values sum up to a given integer target, false otherwise. Problem Example For example, if the input to the function is: const target = 23; ...

Read More

Obtaining maximum number via rotating digits in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 271 Views

We are required to write a JavaScript function that takes in a positive integer n and returns the maximum number we can get by performing only left rotations on the digits of the number. Problem Left rotation means moving the first digit to the end. For example, rotating 12345 once gives 23451, rotating again gives 34512, and so on. We need to find which rotation produces the largest number. Example Let's implement the solution to find the maximum number through left rotations: const num = 56789; const findMaximum = (num = 1) => ...

Read More

What is difference between Microtask Queue and Callback Queue in asynchronous JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 3K+ Views

In asynchronous JavaScript, there are two ways to schedule tasks – microtask queue and callback queue. Both queues are handled differently by the JavaScript engine, with microtasks having higher priority than callbacks. Event Loop Overview The event loop processes tasks in this order: call stack → microtask queue → callback queue. Understanding this priority system is crucial for predicting execution order in asynchronous code. Call Stack (Synchronous) Highest Priority Microtask Queue ...

Read More

How to send row data when clicking the button using javascript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 9K+ Views

When working with HTML tables, you often need to access row data when a user clicks a button. This is useful for editing, deleting, or sending data to a server. We'll explore two methods: vanilla JavaScript and jQuery. Using JavaScript to Access Row Data In this approach, we access the clicked button element, traverse up to find its parent row, then extract all column data from that row. Syntax var clickedRow = clickedElement.parentNode.parentNode.id; var rowData = document.getElementById(clickedRow).querySelectorAll('.column-data'); let text = rowData[0].innerHTML; The clickedRow contains the row ID, rowData contains all columns, and we ...

Read More

Building frequency map of all the elements in an array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

Building a frequency map (also called a frequency counter) is a common programming task that helps count how many times each element appears in an array. This technique is useful for data analysis, finding duplicates, or solving algorithmic problems. A frequency map returns an object where each unique element from the array becomes a key, and its corresponding value represents how many times that element appears. Basic Approach Using forEach() The most straightforward method is to iterate through the array and build an object that tracks the count of each element: const arr = [2, ...

Read More

Greatest element in a Multi-Dimensional Array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 234 Views

We have to write a simple function in JavaScript that takes in an array of Numbers (nested to any level) and return the greatest number present in the array. Problem Example If the input array is: const arr = [ 34, 65, 67, [ 43, 76, 87, 23, 56, 7, [ 54, 7, 87, 23, 79, 994, 2 ], ...

Read More

JavaScript - Finding the third maximum number in an array

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 1K+ Views

In this article, we will learn to find the third maximum unique number in an array of JavaScript, or the largest number if there are fewer than three unique values. We will be using three methods: a single-pass approach for efficiency, a sorting method to identify the number after removing duplicates, and a combination of Set and Max-Heap for optimal handling of large datasets. Problem Statement Given an array of integers, find the third maximum unique number. If the array contains fewer than three unique numbers, return the largest number in the array. Input: const nums = ...

Read More

Remove all occurrences of a multiple occurring element in an array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 955 Views

We are required to write a JavaScript function that takes in an array of literal values. The array might contain some repeating values. Our function should remove all the values from the array that are repeating. We are required to remove all instances of all such elements. Problem Understanding When an element appears multiple times in an array, we want to remove ALL occurrences of that element, not just the duplicates. For example, if 2 appears twice, we remove both instances. Using filter() with indexOf() and lastIndexOf() The most efficient approach uses filter() to keep only ...

Read More

Rearranging array elements in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 337 Views

JavaScript function that takes in an array of literals, arr, as the first and the only argument. This array contains some duplicates placed adjacently. Our function should rearrange the elements of the array such that no two elements in the array are equal. Our function should return the rearranged array, given that it's guaranteed that there exists at least one possible way of such arrangement. Problem Example For example, if the input to the function is: const arr = [7, 7, 7, 8, 8, 8]; Then the output should be: const ...

Read More
Showing 16361–16370 of 61,299 articles
Advertisements