Articles on Trending Technologies

Technical articles with clear explanations and examples

Grouping data to month wise in JavaScript

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

In JavaScript, grouping and sorting data by months is a common requirement when working with date-based information. This involves sorting objects first by year, then by month in chronological order from January to December. Arrays in JavaScript provide powerful methods like sort() and indexOf() that make this task straightforward. The key challenge is properly comparing month names since they need to be sorted in calendar order, not alphabetically. Problem Statement Given an array of objects with year and month properties, we need to sort them chronologically. For example: const data = [ ...

Read More

Checking power of 2 using bitwise operations in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 474 Views

We are required to write a JavaScript function that takes in a number and determines whether or not it is a power of two. For example − f(23) = false f(16) = true f(1) = true f(1024) = true Understanding Powers of Two in Binary Powers of two in binary form always have exactly one bit set to 1: 1: 0001 2: 0010 4: 0100 8: 1000 16: 10000 32: 100000 The Bitwise Approach ...

Read More

In-place Algorithm to Move Zeros to End of List in JavaScript

Aayush Mohan Sinha
Aayush Mohan Sinha
Updated on 15-Mar-2026 1K+ Views

Moving zeros to the end of an array while maintaining the order of non-zero elements is a common programming problem in JavaScript. This article explores two efficient approaches to solve this problem: the in-place two-pointer method and the count-and-fill approach. Problem Statement Given an array containing integers including zeros, we need to move all zeros to the end while preserving the relative order of non-zero elements. The goal is to achieve this efficiently, ideally in a single pass through the array. For example, given the input array: [2, 5, 0, 1, 0, 8, 0, 3] ...

Read More

Can array be divided into n partitions with equal sums in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 302 Views

We are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument and a number, num, as the second argument. The function should determine whether there exists a way of distributing the elements of the array arr into num groups such that all the groups have equal sum. If there exists any such way, our function should return true, false otherwise. For example − If the input array and the number are − const arr = [4, 6, 3, 3, 7, 4, 1]; const num = 4; ...

Read More

Sum of all positives present in an array in JavaScript

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

We are required to write a JavaScript function that takes in an array of numbers (positive and negative). Our function should calculate and return the sum of all the positive numbers present in the array. Method 1: Using reduce() with Helper Function This approach uses a helper function to check if a number is positive and reduce() to accumulate the sum: const arr = [5, -5, -3, -5, -7, -8, 1, 9]; const sumPositives = (arr = []) => { const isPositive = num => typeof num === 'number' && num ...

Read More

Reversing a string while maintaining the position of spaces in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 875 Views

Problem We are required to write a JavaScript function that takes in a string that might contain some spaces. Our function should reverse the non-space characters while keeping spaces in their original positions. Understanding the Task The goal is to reverse only the alphabetic characters while maintaining the exact positions of spaces. For example, "this is normal string" becomes "gnir ts lamron sisiht" - spaces remain at positions 4, 7, and 14. Example Following is the code: const str = 'this is normal string'; const reverseWordsWithin = (str = '') => { ...

Read More

crypto.createVerify() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 974 Views

The crypto.createVerify() method creates and returns a Verify object that uses the specified algorithm for digital signature verification. This method is essential for validating data integrity and authenticity in cryptographic operations. Syntax crypto.createVerify(algorithm, [options]) Parameters The parameters are described as below: algorithm – String that specifies the algorithm name to be used while creating the verify object/instance. You can use crypto.getHashes() to get available signing algorithms. ...

Read More

Explain VirtualizedList component usage in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 3K+ Views

The VirtualizedList component is React Native's most performance-optimized component for rendering large datasets. Unlike regular lists that render all items at once, VirtualizedList only renders visible items and recycles components as users scroll, dramatically improving memory usage and scroll performance. The basic structure of VirtualizedList requires several mandatory props: Essential VirtualizedList Properties Props Description ...

Read More

How to Create Timeline Animations using Anime.js?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 533 Views

In this article, we are going to explore and learn about Timeline Animations. Anime.js is a lightweight JavaScript library that has a small but powerful set of APIs. It works upon the DOM attributes, CSS properties, SVG, and JavaScript objects. We can build multiple and complex animations using the Anime.js. Anime's built-in staggering system helps in making complex follow through and overlapping animations simple. It can also be used on both timings and properties. How to use Anime.js? We can import or use Anime.js in our code in the following two ways: ...

Read More

What is the use of stopPropagation method in JavaScript

Manisha Patil
Manisha Patil
Updated on 15-Mar-2026 701 Views

The stopPropagation() method prevents events from bubbling up through the DOM tree to parent elements. When an event occurs on a child element, it normally triggers on all parent elements too - this method stops that behavior. The Event Bubbling Problem In JavaScript, events "bubble up" from child to parent elements. For example, if a button is inside a div and both have click handlers, clicking the button triggers both events. The stopPropagation() method prevents this propagation. Syntax event.stopPropagation(); Example: Event Bubbling Without stopPropagation Event ...

Read More
Showing 15871–15880 of 61,297 articles
Advertisements