Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to implement backtracking for a climbing stairs practice in JavaScript?
In the given problem statement we are asked to implement backtracking for a climbing stairs practice with the help of JavaScript functionalities. In data structures, backtracking is popularly known to explore all possible solutions. We can solve this problem with the help of a backtracking algorithm. What is the Backtracking Technique? Backtracking is a well-known algorithmic technique, which is basically used to solve problem statements that include searching for all possible solutions. It is based on a depth-first strategy and is used in combination with a recursive method. The basic ideology for this technique is to explore ...
Read MoreChecking for uniqueness in an array in JavaScript
We are required to write a JavaScript function that takes in an array of numbers as the first and the only argument. The function should return true if all the numbers in the array appear only once (i.e., all the numbers are unique), and false otherwise. For example − If the input array is − const arr = [12, 45, 6, 34, 12, 57, 79, 4]; Then the output should be − const output = false; because the number 12 appears twice in the array. Method 1: Using indexOf() ...
Read MoreDeep count of elements of an array using JavaScript
We are required to write a JavaScript function that takes in a nested array of elements and returns the deep count of all elements present in the array, including those in nested subarrays. Problem Given a nested array, we need to count all elements at every level of nesting. Input const arr = [1, 2, [3, 4, [5]]]; Output const output = 7; Because the elements at level 1 are 2, elements at level 2 are 2 and elements at level 3 are 1. Hence the deep count is 7. Using Recursive Reduce Method ...
Read MoreAlternating sum of elements of a two-dimensional array using JavaScript
Problem We are required to write a JavaScript function that takes in a 2-Dimensional array of m X n order of numbers. For this array, our function should calculate the alternating sum where each element is multiplied by (-1)^(i+j), where i and j are the row and column indices respectively. The mathematical formula is: $\sum_{i=1}^m \sum_{j=1}^n (-1)^{i+j}a_{ij}$ How It Works The alternating sum works by applying a positive or negative sign to each element based on its position. When the sum of row index (i) and column index (j) is even, the element gets a positive sign. When ...
Read MoreHow to create a canvas with text cursor on hover over objects using FabricJS?
In this article, we are going to create a canvas with a text cursor on hover using FabricJS. The text cursor is one of the native cursor styles available which can be used in the FabricJS canvas. FabricJS provides various types of cursors such as default, all-scroll, crosshair, col-resize, row-resize, etc. that reuse the native cursor under the hood. The hoverCursor property sets the style of the cursor when hovered over a canvas object. Syntax new fabric.Canvas(element: HTMLElement|String, { hoverCursor: String }: Object) Parameters ...
Read MoreHow to chain asynchronous functions in JavaScript?
JavaScript is a single-threaded language that executes operations synchronously by default. Synchronous operations can be time-consuming and block other operations in the thread. JavaScript provides asynchronous programming capabilities that allow functions to execute without blocking other operations. This is achieved through asynchronous constructs like Promises, async/await, and callbacks. Asynchronous functions are powerful, but their unpredictable execution timing can create challenges. Chaining these functions ensures they execute in a specific order, making your code more predictable and easier to debug. In this article, we will explore different methods for chaining asynchronous functions using modern JavaScript features. The ...
Read MoreHow to set the size of the controlling corners of a Circle using FabricJS?
In this tutorial, we are going to learn how to set the size of the controlling corners of a Circle 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.Circle({ cornerSize: Number }: Object) Parameters options (optional) − This parameter is an ...
Read MoreHow to set the fill colour of a Rectangle using FabricJS?
In this tutorial, we are going to learn how we can change the appearance of a Rectangle object by changing its fill colour using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. We can change the fill colour by using the fill property which allows us to specify the colour of the object's fill. Syntax new fabric.Rect({ fill: String }: Object) Parameters Options (optional) ...
Read MoreHow to find the complexity of a Line instance using FabricJS?
In this tutorial, we are going to learn about how to find the complexity of a 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. In order to get the complexity of a Line object, we use the complexity method. This method will return ...
Read MoreHow to access object properties from result returned by async() function in JavaScript?
In this article, you will understand how to access object properties from result returned by async() functions in JavaScript. An object property in JavaScript is a variable that is associated with the object itself, i.e. the properties have a name and value is one of the attributes linked with the property. When working with async functions that return objects, you can access their properties using standard JavaScript notation once the promise resolves. The key is using await to wait for the promise to resolve before accessing properties. Using Dot Notation In this example, let's understand how to ...
Read More