Articles on Trending Technologies

Technical articles with clear explanations and examples

Explain sub-classes and inheritance in ES6

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

In JavaScript, developers used prototypes for inheritance in ES5. ES6 introduced classes, making inheritance syntax cleaner and more familiar to developers from other programming languages. What are Sub-classes and Inheritance? A subclass is a child class that inherits properties and methods from a parent class (superclass). Inheritance allows you to create new classes based on existing ones, promoting code reuse and establishing hierarchical relationships between classes. The subclass automatically inherits all properties and methods from the superclass and can access them through its objects. You use the extends keyword to create inheritance relationships. Syntax ...

Read More

How to stop browser's back button using JavaScript?

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

Stopping the browser's back button means preventing users from navigating to the previous page. Sometimes, we need to prevent users from going back from the current page for security purposes. For example, most banking sites don't allow you to go back when you are doing transactions through online banking. If users go back mid-transaction, it can create issues. So, they only allow you to either complete the transaction or cancel it and start again. Here, we will learn various approaches to prevent users from going back to the previous web page using JavaScript. Using window.history.forward() Method ...

Read More

Return the index of first character that appears twice in a string in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 344 Views

We are required to write a JavaScript function that takes in a string and returns the index of the first character that appears twice in the string. If there is no such character then we should return -1. Syntax function firstRepeating(str) { // Implementation here } Example The code for this will be − const str = 'Hello world, how are you'; const firstRepeating = str => { const map = new Map(); for(let i = 0; i < ...

Read More

Sort the second array according to the elements of the first array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 303 Views

Suppose, we have two arrays like these − const arr1 = ['d', 'a', 'b', 'c']; const arr2 = [{a:1}, {c:3}, {d:4}, {b:2}]; console.log("First array:", arr1); console.log("Second array:", arr2); First array: [ 'd', 'a', 'b', 'c' ] Second array: [ { a: 1 }, { c: 3 }, { d: 4 }, { b: 2 } ] We are required to write a JavaScript function that accepts these two arrays. The function should sort the second array according to the elements of the first array. We have to sort the keys of ...

Read More

Complete Equation by Filling Missing Operator in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 523 Views

We are required to write a JavaScript function that takes in a bunch of numbers and returns the correct sequence of operations to satisfy the equation. The operators that can be used are (+, −, *, /, ^, %). For example − Input : 5 3 8 Output : 5+3=8 Input : 9 27 3 Output : 9=27/3 Input : 5 2 25 , 1 5 2 Output : 5^2=25 , 1=5%2 For each input, there is at ...

Read More

Create an object based on 2 others in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 174 Views

In JavaScript, you often need to combine properties from multiple objects into a new one. There are several modern approaches to achieve this without modifying the original objects. Problem Statement Given two objects with properties and methods, we want to create a third object that contains all properties from both: const a = { a: 1, af: function() { console.log(this.a) }, }; const b = { b: 2, bf: function() { console.log(this.b) }, }; // Goal: Create object ...

Read More

Number pattern in JavaScript

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

Number patterns in JavaScript are essential for developers who want to create visually appealing outputs and understand algorithmic thinking. These patterns involve generating sequences of numbers that follow specific rules or arrangements, helping developers grasp mathematical concepts that underlie complex algorithms. What are Number Patterns? Number patterns are sequences of numbers arranged in specific formations, typically displayed in triangular or pyramid structures. Each pattern follows a mathematical rule that determines how numbers are positioned and incremented. Pattern 1: Zero-Padded Triangle This pattern creates a triangular structure where each row contains numbers from 1 to the row ...

Read More

Searching for target string in a strangely sorted array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 196 Views

We are required to write a JavaScript function that takes in a word target and an array of sorted(by length(increasing), number of uppercase letters(decreasing), natural order) unique words which always contains the target. The task of our function is to find the index(0 based) of the target in the array of words, which would always be in the list. Understanding the Sorting Pattern The array is sorted by three criteria in order: Length: Shorter strings come first Uppercase count: Among same-length strings, more uppercase letters come first ...

Read More

How to create the instance of fabric.Image from a URL string using FabricJS?

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

In this tutorial, we are going to learn how to create the instance of fabric.Image from a URL string using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to create the instance of fabric.Image from a URL string, we use the fromURL method. Syntax fabric.Image.fromURL(url, callback, imgOptions) Parameters url − This parameter accepts a String which denotes the URL to create an image ...

Read More

How to make a star with Polygon class using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 767 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
Showing 14481–14490 of 61,297 articles
Advertisements