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
Find Hypotenuse of a Number In TypeScript
The longest side of a right-angled triangle and the side that faces away from the right angle is known as the hypotenuse. The Pythagorean theorem states that the hypotenuse's square equals the sum of the squares of the other two sides. The formula is c² = a² + b², where c is the hypotenuse and a and b are the triangle's two sides. In TypeScript, we can create functions to calculate the hypotenuse using the Pythagorean theorem. The function accepts the lengths of the two shorter sides as parameters and returns the hypotenuse length. This only works for right ...
Read MoreHow to create a new object from the specified object, where all the keys are in lowercase in JavaScript?
There are many methods for creating new objects from older ones in JavaScript. Creating a new object with the same keys as an existing object but with all the keys in lowercase is a common use case. When working with data from many sources that have irregular key casing, this can be helpful. We'll look at various JavaScript ways to create new objects with lowercase keys in this blog post. However, before doing so, it's important to remember that while creating a new object with lowercase keys might be helpful when working with data from various sources, it's also ...
Read MoreSwapping letter with succeeding alphabet in JavaScript
We are required to write a JavaScript function that takes in a string and changes every letter of the string from the English alphabets to its succeeding element. For example: If the string is − const str = 'how are you'; Output Then the output should be − const output = 'ipx bsf zpv' Therefore, let's write the code for this function − How It Works The algorithm converts each alphabetic character to its next letter in the alphabet. For 'z' and 'Z', it wraps around to 'a' ...
Read MoreMerge two sorted arrays to form a resultant sorted array in JavaScript
We are required to write a JavaScript function that takes in two sorted arrays of numbers. The function should merge the two arrays together to form a resultant sorted array and return that array. For example, if the two arrays are: const arr1 = [2, 6, 6, 8, 9]; const arr2 = [1, 4, 5, 7]; Then the output array should be: [1, 2, 4, 5, 6, 6, 7, 8, 9] Method 1: Using Two Pointers Technique The most efficient approach is the two-pointers technique, which compares elements from both ...
Read MoreJavaScript: Adjacent Elements Product Algorithm
In this article, we will learn to calculate the adjacent elements product with the help of JavaScript functionalities. This problem is often asked in coding interviews or algorithm challenges, and it tests one's understanding of array manipulation and performance optimization. Problem Statement Given an array of integers, your task is to return the largest product that can be obtained by multiplying any two adjacent numbers in the array. For example − Input: [5, 1, 2, 3, 1] Output: 6 The adjacent elements are (5, 1), (1, 2), (2, 3), and (3, 1). The largest ...
Read MoreFinding all solutions of a Diophantine equation using JavaScript
Problem We need to write a JavaScript function that takes a number n and finds all integer solutions (x, y) for the Diophantine equation: x^2 - 4y^2 = n The function should return an array of all such pairs [x, y]. Mathematical Approach To solve x² - 4y² = n, we can factorize it as: x^2 - 4y^2 = (x + 2y)(x - 2y) = n Let a = x - 2y and b = x + 2y, then: a × b = n x = (a + ...
Read MoreHow to disable the centered rotation of a Circle using FabricJS?
In this tutorial, we are going to learn how to disable the centered rotation of Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will create an instance of fabric.Circle class and add it to the canvas. By default, all objects in FabricJS use their center as the point of rotation. However, we can change this behaviour by using the centeredRotation property. Syntax new fabric.Circle({ centeredRotation: Boolean }: Object) Parameters options (optional) ...
Read MoreHow to lock the horizontal skewing of Textbox using FabricJS?
In this tutorial, we are going to learn how to lock the horizontal skewing of a Textbox using FabricJS. Just as we can specify the position, colour, opacity and dimension of a textbox object in the canvas, we can also specify whether we want to stop skewing an object horizontally. This can be done by using the lockSkewingX property. Syntax new fabric.Textbox(text: String, { lockSkewingX : Boolean }: Object) Parameters text − This parameter accepts a String which is the text string that we want to display inside our ...
Read MoreHow to center an object horizontally with respect to current viewport of canvas in IText using FabricJS?
In this tutorial, we are going to learn about how to center an object horizontally with respect to current viewport of canvas in IText using FabricJS. The IText class was introduced in FabricJS version 1.4, extends fabric.Text and is used to create IText instances. An IText instance gives us the freedom to select, cut, paste or add new text without additional configurations. There are also various supported key combinations and mouse/touch combinations which make text interactive which are not provided in Text. Textbox, however, which is based on IText allows us to resize the text rectangle and wraps lines ...
Read MoreHow to find the complexity of an Image instance using FabricJS?
In this tutorial, we are going to learn how to find the complexity of an Image instance 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 find the complexity of an Image instance, we use the complexity method. This method will return 1 if the current object is directly inherited from a base class and not from a subclass. Syntax complexity(): Number Using the ...
Read More