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
WebDriver click() vs JavaScript click().
In Selenium WebDriver, there are two primary methods to click elements: the standard WebDriver click() method and JavaScript click() through JavaScriptExecutor. Each approach has distinct advantages and use cases. WebDriver click() Method The standard WebDriver click() simulates actual user interaction. It waits for the element to be visible and clickable before performing the action. This method works with various locators including link text and partial link text. WebDriver click() Browser Engine ...
Read MoreAdding binary strings together JavaScript
The problem is stating that we have to add two binary strings. Binary strings are a sequence of bytes. To add them in JavaScript, we will first convert them to decimal and calculate the sum. After adding those decimal numbers, we will convert it again into binary strings and print the output. What are Binary Strings? Binary numbers or binary strings are sequences of bytes in base 2. It is basically a combination of 0 and 1 to represent any number. Binary addition is one of the fundamental operations in computer science and works similarly to decimal addition, ...
Read MoreHow to disable selection of objects via dragging in a canvas using FabricJS?
In this article, we are going to illustrate how you can disable the selection of objects via dragging in FabricJS. In a FabricJS canvas, we can basically click anywhere and select an area and any object in that area will get selected. In this article, we will see how to disallow this behavior. Syntax new fabric.Canvas(element: HTMLElement|String, {selection: boolean}: Object) Parameters element − This parameter is the element itself which can be derived using document.getElementById() or the id of the element ...
Read MoreHow to set the angle of rotation of a Rectangle using FabricJS?
In this tutorial, we are going to set the angle of rotation of a Rectangle 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. The angle property in FabricJS defines the angle of 2D rotation of an object. We also have the centeredRotation property that allows us to use the center point of a rectangle as the origin of transformation. Syntax new fabric.Rect({ angle: Number, centeredRotation: Boolean }) Parameters ...
Read MoreFabricJS – How to set the size of the controlling corners of a Line?
In this tutorial, we are going to learn how to set the size of the controlling corners of Line 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.Line( points: Array, { cornerSize: Number }: Object) Parameters points − This parameter accepts an Array of points which determines the ...
Read MoreHow to straighten an Image with animation using FabricJS?
In this tutorial, we are going to learn how to straighten an Image with animation 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 straighten an Image with animation, we use the fxStraighten method. Syntax fxStraighten(callbacks: Object): fabric.Object Parameters callbacks − This parameter is an Object with callback functions which can be used to change certain properties related to ...
Read MoreFinding the continuity of two arrays in JavaScript
We are required to write a JavaScript function that takes in two arrays of numbers. The function should return true if the two arrays upon combining can form a consecutive sequence, false otherwise. For example: If the arrays are − const arr1 = [4, 6, 2, 9, 3]; const arr2 = [1, 5, 8, 7]; When combined and sorted, these arrays form [1, 2, 3, 4, 5, 6, 7, 8, 9], which is a consecutive sequence. Therefore, the output should be true. Understanding Consecutive Sequences A consecutive sequence means each number is exactly ...
Read MoreGet average of every group of n elements in an array JavaScript
In JavaScript, calculating the average of every group of n elements in an array involves dividing the array into chunks and computing the mean for each group. This is useful for data analysis, batch processing, and statistical calculations. Understanding the Problem Given an array of numbers, we need to group consecutive elements into chunks of size n, then calculate the average of each group. For example, with array [1, 2, 3, 4, 5, 6] and group size 2, we get groups [1, 2], [3, 4], [5, 6] with averages [1.5, 3.5, 5.5]. Array Grouping ...
Read MoreFinding the nth element of the lucas number sequence in JavaScript
Lucas numbers are a sequence similar to Fibonacci numbers but with different starting values. They follow a specific mathematical pattern where each number is the sum of the two preceding ones. Lucas Number Sequence Definition The Lucas sequence is defined as: L(0) = 2 L(1) = 1 L(n) = L(n-1) + L(n-2) for n ≥ 2 The sequence starts: 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123... Problem Statement We need to write a JavaScript function that takes a number n and returns the nth Lucas number from the ...
Read MoreFinding value of a sequence for numbers in JavaScript
In JavaScript, we can calculate the value of mathematical sequences using loops and built-in Math functions. This article demonstrates how to implement a specific sequence formula that involves alternating signs, powers, and fractions. Problem Consider the following sequence sum: $$seq(n, \:p)=\displaystyle\sum\limits_{k=0}^{n}(-1)^{k}\times\:p\:\times 4^{n-k}\:\times\frac{2n-k}{k}$$ We need to write a JavaScript function that takes numbers n and p and returns the value of seq(n, p). The sequence includes alternating signs, exponential terms, and fractional components. Understanding the Formula The sequence contains several key components: (-1)^k - Creates alternating positive and negative terms p - A ...
Read More