Articles on Trending Technologies

Technical articles with clear explanations and examples

JavaScript: How to remove the key-value pairs corresponding to the given keys from an object?

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

In JavaScript, objects store data as key-value pairs. You can access object data using dot notation (obj.key) or bracket notation (obj["key"]). Sometimes you need to remove specific key-value pairs from an object. Here are three effective methods to accomplish this. Using the delete Operator The delete operator is the most straightforward way to remove a property from an object. It permanently removes both the key and its value. Delete Operator Example ...

Read More

Changing the case of a string using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 255 Views

We are required to write a JavaScript function that takes in a string and converts it to snake case. Snake case is basically a style of writing strings by replacing the spaces with '_' and converting the first letter of each word to lowercase. Example The code for this will be − const str = 'This is a simple sentence'; const toSnakeCase = (str = '') => { const strArr = str.split(' '); const snakeArr = strArr.reduce((acc, val) => { ...

Read More

Add all records from one array to each record from a different array in JavaScript

Sakshi Jain
Sakshi Jain
Updated on 15-Mar-2026 601 Views

In JavaScript, you may need to combine elements from two arrays where each record from one array pairs with every record from another array. This creates a Cartesian product - every possible combination of elements from both arrays. What is a Cartesian Product? A Cartesian product is a mathematical concept where given two sets A and B, A × B represents every possible combination of elements from both sets. In JavaScript, this translates to pairing each element from the first array with every element from the second array. For example, given two arrays: const array1 ...

Read More

Matching odd even indices with values in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 276 Views

We are required to write a JavaScript function that takes in an array of numbers. The array given as an input to the function have two special properties − The length of the array will always be an even number. The number of even numbers and the number of odd numbers in the array will always be equal (i.e., both being equal to the half of the length of array) The function should shuffle the elements of the array such that all the even values occupy even indices ...

Read More

How to create a Circle with help cursor on hover over objects using FabricJS?

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

In this tutorial, we will learn how to create a Circle with a help cursor on hover using FabricJS. The help cursor is one of the native cursor styles available which can be used in FabricJS canvas. FabricJS provides various cursor types like default, all-scroll, crosshair, col-resize, and row-resize, all reusing native cursor styles. The hoverCursor property controls the cursor style when hovering over a canvas object. Syntax new fabric.Circle({ hoverCursor: String }: Object) Parameters options (optional) − An Object providing additional customizations ...

Read More

How to create a moving div using JavaScript?

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

A moving div is a web page element that can be animated to move across the screen by modifying its position properties. Creating a moving div using JavaScript requires HTML for structure, CSS for positioning, and JavaScript for the animation logic. In this tutorial, we will learn how to create a moving div using JavaScript. HTML Structure First, we need a div element with a unique ID that we can target with JavaScript: This is my moving div! CSS Styling The CSS sets the initial position and appearance. We use position: relative to ...

Read More

How to convert angular 4 application to desktop application using electron?

Prerna Tiwari
Prerna Tiwari
Updated on 15-Mar-2026 2K+ Views

Utilizing web technologies like JavaScript, HTML, and CSS, you can create cross-platform desktop applications using the popular framework Electron. This article will guide you through converting an Angular 4 application into a desktop application using Electron. Prerequisites Before starting, ensure you have: Node.js installed on your system An existing Angular 4 application (built and ready) Basic knowledge of Angular and Node.js Setting Up Electron Follow these steps to set up Electron for your Angular application: Step 1: Install Electron Navigate to your Angular project directory ...

Read More

Vowel gaps array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 180 Views

We are required to write a JavaScript function that takes in a string with at least one vowel, and for each character in the string we have to map a number representing its nearest distance from a vowel. For example: If the string is − const str = 'vatghvf'; Output Then the output should be − const output = [1, 0, 1, 2, 3, 4, 5]; The logic is: 'v' is 1 position away from vowel 'a', 'a' is 0 (it's a vowel), 't' is 1 away from 'a', 'g' ...

Read More

Inverting a binary tree in JavaScript

Sakshi Jain
Sakshi Jain
Updated on 15-Mar-2026 902 Views

Inverting a binary tree means creating a mirror image where all left and right child nodes are swapped recursively. This is a classic tree manipulation problem that demonstrates recursion and tree traversal concepts. What is a Binary Tree? A binary tree is a hierarchical data structure where each node has at most two children: left and right. The topmost node is called the root, and nodes with no children are called leaves. 4 2 7 ...

Read More

Sort an integer array, keeping first in place in JavaScript

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

In JavaScript, when you need to sort an integer array while keeping the first element in its original position, you can combine array slicing with the built-in sort method. This approach preserves the first element while sorting the remaining elements. Understanding the Problem The task is to sort an integer array in ascending order while keeping the first element at index 0. For example, if you have an array [4, 7, 8, 5, 6, 1, 3], the result should be [4, 1, 3, 5, 6, 7, 8] ...

Read More
Showing 14821–14830 of 61,297 articles
Advertisements