Articles on Trending Technologies

Technical articles with clear explanations and examples

How to unflatten a JavaScript object in a daisy-chain/dot notation into an object with nested objects and arrays?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 616 Views

When working with flattened objects that use dot notation (like "car.make" or "visits.0.date"), you often need to convert them back into nested objects and arrays. This process is called "unflattening" and is useful when working with form data, APIs, or database results. The Problem Suppose we have a flattened object like this: const obj = { "firstName": "John", "lastName": "Green", "car.make": "Honda", "car.model": "Civic", "car.revisions.0.miles": 10150, "car.revisions.0.code": "REV01", ...

Read More

How to convert nested array pairs to objects in an array in JavaScript ?

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

When working with complex data structures, you often need to convert nested array pairs into objects. This is common when processing form data or API responses that use key-value pair arrays. Problem Statement Suppose we have an array of arrays like this: const arr = [ [ ['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk'] ], ...

Read More

Removing comments from array of string in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 427 Views

We are required to write a JavaScript function that takes in array of strings, arr, as the first argument and an array of special characters, starters, as the second argument. The starter array contains characters that can start a comment. Our function should iterate through the array arr and remove all the comments contained in the strings. Problem Example For example, if the input to the function is: const arr = [ 'red, green !blue', 'jasmine, #pink, cyan' ]; const starters = ['!', '#']; Then the output ...

Read More

Adding Animations to a Webpage using Velocity.js

Mukul Latiyan
Mukul Latiyan
Updated on 15-Mar-2026 597 Views

Animations have become a very integral part of website interfaces in today's web development world. They help in enhancing the user experience of a website and in this article, we will learn how we can make use of Velocity.js to add beautiful animations to our web pages. VelocityJS is a JavaScript animation engine that provides us with very fast performing animations that we can use in our web pages. It has become one of the leading animation engines and there are different reasons for its success. I have mentioned some of the most important reasons that make it a ...

Read More

How to draw a rectangle with Polygon object using FabricJS?

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

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. Syntax new fabric.Polygon(points: Array, options: Object) Parameters points − This parameter accepts an Array which denotes the array of points that make up the polygon object. ...

Read More

Top Reasons to Learn JavaScript

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 306 Views

Learning a new programming language is an additional advantage to a developer. Before learning JavaScript, developers should get a basic idea of HTML and CSS. You will be wondering why it is essential to learn JavaScript. Other programming languages are also available in Information Technology. Of course, all programming languages are necessary for a developer. But JavaScript is the foundation for all. Knowing HTML, CSS and JavaScript make you an adaptable developer. Popular and Widely Used Both front-end developers and back-end developers use JavaScript. Among 1.8 billion websites in the world, 95% of the websites use JavaScript. ...

Read More

How to close a current tab in a browser window using JavaScript?

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

We will learn to close the browser window using JavaScript in this tutorial. Suppose users have opened your website in 2 tabs and don't want to allow it, then you can close one tab automatically using JavaScript. Also, if you have noticed that some web apps automatically open the browser window to capture a face, it closes automatically when you capture the image by clicking the button. It's all we can do using JavaScript. This tutorial will teach different examples of closing the current tab in a browser window using JavaScript. Note − JavaScript never allows developers ...

Read More

How to merge specific elements inside an array together - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 174 Views

When working with arrays containing mixed data types, you might need to merge consecutive numeric elements while keeping certain separators intact. This is common when processing data that represents grouped numbers. Let's say we have the following array: var values = [7, 5, 3, 8, 9, '/', 9, 5, 8, 2, '/', 3, 4, 8]; console.log("Original array:", values); Original array: [7, 5, 3, 8, 9, '/', 9, 5, 8, 2, '/', 3, 4, 8] Using join() and split() Method To merge specific elements while preserving separators, we can use join(), split(), ...

Read More

Get all methods of any object JavaScript

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

In JavaScript, you can extract all methods (functions) from any object using Object.getOwnPropertyNames() combined with type filtering. This is useful for debugging, reflection, or dynamically working with object methods. Understanding the Problem Objects contain both properties (data) and methods (functions). To get only the methods, we need to: Get all property names from the object Filter properties where the value type is "function" Return an array of method names Using Object.getOwnPropertyNames() The Object.getOwnPropertyNames() method returns an array of all properties (enumerable and non-enumerable) found directly on the given object. We then filter this ...

Read More

Sort an array of objects by multiple properties in JavaScript

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

Sorting an array of objects by multiple properties is a common requirement in JavaScript applications. This involves creating custom comparison logic that prioritizes different properties based on specific criteria. Suppose, we have an array of objects like this: const arr = [ { id: 1, score: 1, isCut: false, dnf: false }, { id: 2, score: 2, isCut: false, dnf: false }, { id: 3, score: 3, isCut: false, dnf: false }, { id: 4, score: 4, isCut: false, dnf: false ...

Read More
Showing 16611–16620 of 61,297 articles
Advertisements