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 add dashed stroke to an Ellipse using FabricJS?
In this tutorial, we are going to learn how to add a dashed stroke to an Ellipse using FabricJS. Ellipse is one of the various shapes provided by FabricJS. In order to create an ellipse, we will create an instance of fabric.Ellipse class and add it to the canvas. The strokeDashArray property allows us to specify a dash pattern for the object's stroke. Syntax new fabric.Ellipse({ strokeDashArray: Array }: Object) Parameters options (optional) − This parameter is an Object which provides additional customizations ...
Read MoreHow to add dashed stroke to a Textbox using FabricJS?
In this tutorial, we are going to learn how to add a dashed stroke to a Textbox using FabricJS. We can customize, stretch or move around the text written in a textbox. In order to create a textbox, we will have to create an instance of fabric.Textbox class and add it to the canvas. The strokeDashArray property allows us to specify a dash pattern for the object's stroke. Syntax new fabric.Textbox(text: String, { strokeDashArray: Array }: Object) Parameters text − This parameter accepts ...
Read MoreHow to use the JavaScript function in the check box?
While working with HTML checkboxes, developers often need to execute JavaScript functions based on user interactions. This allows for dynamic content updates, form validation, and conditional display of elements based on checkbox selections. For example, you might have a checkbox asking "Are you above 18?" If users check this checkbox, you can show additional input fields like a PAN card number field. This requires calling JavaScript functions whenever users check or uncheck checkboxes. Using the onchange Event The onchange event attribute allows us to invoke a function whenever the user checks or unchecks a checkbox. This event ...
Read MoreGenerate Ranking with combination of strings in JavaScript
We are required to write a JavaScript function that takes in any number of arrays of numbers and generates a frequency map of all possible combinations within each array. The function counts how many times each element and combination appears across all arrays. For example, if we have the following arrays: const a = [23, 45, 21], b = [45, 23], c = [21, 32], d = [23], e = [32], f = [50, 54]; The function should ...
Read MoreEvaluating a string as a mathematical expression in JavaScript
We are required to write a JavaScript function that takes in a stringified mathematical equation. The function should return the result of the equation provided to the function. For example: If the equation is − const str = '1+23+4+5-30'; Then the output should be 3 Example The code for this will be − const str = '1+23+4+5-30'; const compute = (str = '') => { let total = 0; str = str.match(/[+\-]*(\.\d+|\d+(\.\d+)?)/g) || []; while (str.length) { ...
Read MoreSum array of rational numbers and returning the result in simplest form in JavaScript
We are required to write a JavaScript function that takes in an array of exactly two subarrays with two numbers each. Both the subarrays represent a rational number in fractional form. Our function should add the rational numbers and return a new array of two numbers representing the simplest form of the added rational number. Problem When adding two fractions like 1/2 + 1/3, we need to: Find a common denominator Add the numerators Simplify the result using the Greatest Common Factor (GCD) Solution The mathematical formula for adding fractions is: a/b + ...
Read MoreBreaking camelCase syntax in JavaScript
We need to write a JavaScript function that takes a camelCase string and converts it into a readable format by adding spaces before uppercase letters. Our function should construct and return a new string that splits the input string using a space between words. Problem Example For example, if the input to the function is: Input const str = 'thisIsACamelCasedString'; Expected Output 'this Is A Camel Cased String' Solution Using String Iteration The approach iterates through each character and adds a space before uppercase letters (except the first character): ...
Read MoreHow to add shadow to an Ellipse using FabricJS?
In this tutorial, we are going to learn how to add a shadow to an Ellipse using FabricJS. Ellipse is one of the various shapes provided by FabricJS. In order to create an ellipse, we will create an instance of fabric.Ellipse class and add it to the canvas. Our ellipse object can be customized in various ways like changing its dimensions, adding a background color or even adding a shadow to it. We can add a shadow to an Ellipse by using the shadow property. Syntax new fabric.Ellipse({ shadow : fabric.Shadow }: Object) Parameters ...
Read MoreHow to use map and filter simultaneously on an array using JavaScript?
The filter() method creates a new array with elements that pass a test, while map() transforms each element into something new. When used together, they provide a powerful way to both filter and transform data in a single chain. This combination is particularly useful when you need to process only certain elements of an array and then transform them. For example, filtering positive numbers and then calculating their square roots, or selecting employees with specific criteria and updating their salaries. Syntax of array.filter() method array.filter((element, index, self) => { // write a condition ...
Read MoreJavaScript: Combine highest key values of multiple arrays into a single array
We are required to write a JavaScript function that takes in any number of arrays of numbers. Our function should return an array of greatest numbers picked from the corresponding positions of the input arrays. The number of elements in the output array should be equal to the length of the longest input array. Problem Understanding Given multiple arrays, we need to compare elements at the same index positions and select the maximum value from each position to form a new array. Example The code for this will be: const arr1 = [117, 121, ...
Read More