Articles on Trending Technologies

Technical articles with clear explanations and examples

Retrieve property value selectively from array of objects in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 358 Views

When working with arrays of objects in JavaScript, you often need to extract specific property values based on certain conditions. This tutorial shows how to retrieve property values selectively from an array of objects. Suppose we have an array of objects like this: const arr = [ { id : "23", name : "Item 1", isActive : true}, { id : "25", name : "Item 2", isActive : false}, { id : "26", name : "Item 3", isActive : false}, { id : "30", name ...

Read More

Removing all non-alphabetic characters from a string in JavaScript

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

Non-alphabetic characters are any characters that are not part of the alphabet, and the strings are a data type that represents a sequence of characters or text. Working with strings is a basic task in JavaScript, and one common task is removing all non-alphabetic characters from a string. In this article, we will understand how to remove all non-alphabetic characters from a string. Understanding the Problem Suppose we have a string saying "he@656llo wor?ld". We want to remove all digits, punctuation, whitespace, and special characters from the given string. For example: Input string we have: "he@656llo wor?ld" ...

Read More

Distance of nearest 0 in binary matrix in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 281 Views

A binary matrix is an array of arrays containing only 0 or 1. We are required to write a JavaScript function that takes in a binary matrix as the only argument. Our function should create a new matrix containing the same number of rows and columns, and for each element of the original matrix the resulting matrix should contain that element's nearest distance from 0 in the original matrix. We have to keep in mind that while calculating distance it can move either horizontally or vertically and not diagonally. And it's guaranteed that the matrix contains at least ...

Read More

Constructing an array of addition/subtractions relative to first array element in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 193 Views

We are required to write a JavaScript function that takes in an array of positive integers. Our function should map this array to an array of string integers. The array should contain the number we should add/subtract to the first element to achieve the corresponding element. Problem For example, if we have: [4, 3, 6, 2] We need to calculate the difference between each element and the first element (4): 4 - 4 = 0 → "+0" 3 - 4 = -1 → "-1" 6 - 4 = 2 → "+2" 2 ...

Read More

How to avoid jQuery function conflict with any other JavaScript library

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we will learn how to avoid jQuery function conflict with any other JavaScript library. For the jQuery function, the $ symbol is simply an identifier. A $ followed by a selector indicates that it is a jQuery selector. It is given a shorter identification as $ to save time while writing longer syntax. It includes all of the functions needed by a jQuery object, such as animation(), show(), hide(), CSS, and many others. Furthermore, $ is superior in terms of memory to jQuery because $ takes a byte while jQuery uses 6 bytes for the same ...

Read More

FabricJS – How to set the colour of the controlling corners of a Line?

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

In this tutorial, we are going to learn about how to set the colour of the controlling corners of Line using FabricJS. A Line element is one of the basic elements provided in FabricJS. It is used for creating straight lines. Because line elements are geometrically one-dimensional and do not contain an interior, they are never filled. We can create a line object by creating an instance of fabric.Line, specifying the X and Y coordinates of the line and adding it to the canvas. The cornerColor property allows us to manipulate the colour of the controlling corners when the object ...

Read More

How to use polyfill in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

The developers of JavaScript always keep adding new features to the JavaScript language to improve performance and add better functionalities. Sometimes, it happens that new features don't support by the old browser versions. For example, the exponential operator is introduced in ES7, and the trailing comma in the object is also valid in ES7. Now, while developing the application, we have used the exponential operator in the application. It will work with the newer versions of the browser, but if someone is using a very old version of the browser, they can get errors like the exponential operator is ...

Read More

Clear element.classList in JavaScript?

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

The task we are going to perform in this article is clear element classList in JavaScript. The classList property provides methods to add, remove, toggle, and check CSS classes on HTML elements. All element objects (i.e., objects that represent elements) in a Document derive from the most general base class called Element. It contains functions and characteristics that apply to all types of elements. What is classList in JavaScript JavaScript classList is a DOM property that enables manipulation of an element's CSS classes. The read-only classList property returns a DOMTokenList containing the CSS class names of an ...

Read More

Add time to string data/time - JavaScript?

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

In JavaScript, you can add time to a date/time string using the Date object's built-in methods. This is useful for calculating future times or adjusting existing timestamps. Basic Approach First, create a Date object from your string, then use methods like setHours(), setMinutes(), or setSeconds() combined with their getter counterparts to add time. var dateValue = new Date("2021-01-12 10:10:20"); dateValue.setHours(dateValue.getHours() + 2); // Add 2 hours Example: Adding Hours to Date String var dateValue = new Date("2021-01-12 10:10:20"); console.log("Original date: " + dateValue.toString()); // Add 2 hours dateValue.setHours(dateValue.getHours() + 2); ...

Read More

Calculate the hypotenuse of a right triangle in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 790 Views

We are required to write a JavaScript function that takes in two numbers. The first number represents the length of the base of a right triangle and the second is perpendicular. The function should then compute the length of the hypotenuse based on these values. For example − If base = 8, perpendicular = 6 Then the output should be 10 The Pythagorean Theorem The hypotenuse is calculated using the Pythagorean theorem: c² = a² + b², where c is the hypotenuse and a, b are the other two sides. ...

Read More
Showing 11871–11880 of 61,303 articles
Advertisements