Articles on Trending Technologies

Technical articles with clear explanations and examples

How to iterate json array - JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 7K+ Views

In JavaScript, iterating over JSON arrays is a common task when working with data from APIs or configuration files. A JSON array is an ordered list of values that can contain strings, numbers, booleans, objects, or other arrays. This article demonstrates various methods to iterate through JSON arrays in JavaScript, from traditional loops to modern ES6+ approaches. Understanding JSON Arrays JSON arrays are ordered collections of values enclosed in square brackets. Each element is separated by commas and can be accessed using numeric indices. Syntax [ { ...

Read More

Find the Exact Individual Count of Array of String in Array of Sentences in JavaScript

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

In JavaScript, you often need to count how many times specific strings appear in an array of sentences. This article demonstrates how to find the exact individual count of each string from a given array within multiple sentences using regular expressions and word boundaries. Understanding the Problem Given an array of strings and an array of sentences, we need to count how many times each string appears across all sentences. The key requirement is to match complete words only, not partial matches within other words. ...

Read More

Sum of two elements just less than n in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 209 Views

We are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument and a single number, num, as the second argument. The function should then find two such numbers whose sum is greatest in the array but just less than the number num. If there exists no two such numbers whose sum is less than num, our function should return -1. Problem Statement Given an array of numbers and a target value, find the maximum sum of any two elements that is still less than the target. For ...

Read More

Counting divisors of a number using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 633 Views

We are required to write a JavaScript function that takes in a number and returns the count of its divisors. Problem Statement Input: const num = 30; Expected Output: const output = 8; Because the divisors of 30 are: 1, 2, 3, 5, 6, 10, 15, 30 Method 1: Simple Iteration Approach The straightforward approach is to iterate through all numbers from 1 to the given number and count those that divide evenly. const countDivisorsSimple = (num) => { ...

Read More

crypto.pbkdf2() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 2K+ Views

The crypto.pbkdf2() method in Node.js implements the Password-Based Key Derivation Function 2 (PBKDF2) algorithm. It derives a cryptographic key from a password using a salt and multiple iterations to enhance security against brute-force attacks. Syntax crypto.pbkdf2(password, salt, iterations, keylen, digest, callback) Parameters The parameters are described as follows: password – The password string used for key derivation. Accepts string, Buffer, TypedArray, or DataView. ...

Read More

How to disable uniform scaling in canvas using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 1K+ Views

In this article, we are going to learn about how to disable uniform scaling in canvas using FabricJS. In FabricJS, an object gets transformed proportionally when dragged from the corners. However, we can disable this behavior by using the uniformScaling property. Syntax new fabric.Canvas(element: HTMLElement|String, { uniformScaling: Boolean }: Object) Parameters element − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element. options (optional) ...

Read More

How to set the size of the controlling corners of Rectangle using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 376 Views

In this tutorial, we are going to learn how to set the size of the controlling corners of a Rectangle using FabricJS. The controlling corners of an object allow us to scale, stretch or change its position. We can customize our controlling corners in many ways such as adding a specific colour to it, changing its size etc. We can change the size by using the cornerSize property. Syntax new fabric.Rect({ cornerSize: Number }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations to ...

Read More

Add class name in different li by pure in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 2K+ Views

Adding class names to different list items (li elements) is a common task in JavaScript DOM manipulation. This can be achieved using various methods like forEach() with classList.add(), CSS selectors, or DOM traversal properties. Let's explore different approaches to add class names to list items using pure JavaScript. Method 1: Using forEach() with classList.add() The forEach() method executes a function for each array element, while classList.add() adds one or more CSS classes to an element. Syntax array.forEach(function(currentValue, index, arr), thisValue) element.classList.add('className') Example ...

Read More

JavaScript - Sort key value pair object based on value?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 4K+ Views

By using JavaScript's native array methods and functions, we can easily create custom sorting algorithms that will work for any type of object. In this article, we will discuss how to use these techniques in order to sort an object's key-value pairs by value. A key-value pair in JavaScript such as maps, dictionaries stores one value (the "key") associated with another value (the "value"). It can be used to store and access data quickly, as each element has its own unique identifier. For sorting key value pair object based on the value, we use sort() method in JavaScript. ...

Read More

Sort nested array containing objects ascending and descending according to date in JavaScript

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

Suppose we have a JSON Object that contains a nested array like this: const arr = { "DATA": [ { "BookingID": "9513", "DutyStart": "2016-02-11 12:00:00" }, { "BookingID": "91157307", "DutyStart": "2016-02-11 13:00:00" }, { "BookingID": "95117317", "DutyStart": "2016-02-11 13:30:00" ...

Read More
Showing 15751–15760 of 61,297 articles
Advertisements