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 create a canvas with Textbox using FabricJS?
In this tutorial, we are going to learn about how to create a canvas with a Textbox object using FabricJS. We can customize, stretch or move around the text written in a textbox. We can also customize the text itself by using properties like fontSize, fontFamily, fontStyle, fontWeight, etc. In order to create a textbox, we will have to create an instance of fabric.Textbox class and add it to the canvas. Syntax new fabric.Textbox(text: String, options: Object) Parameters text − This parameter accepts a String which is the text string ...
Read MoreHow to design hit the mouse game using HTML, CSS and JavaScript?
In this tutorial, we are going to build the famous hit the mouse game using HTML, CSS, and vanilla JavaScript. Many of you wondering what is Vanilla JavaScript, it is nothing just plain JavaScript written without the use of any libraries. In the hit the mouse game, the player needs to hit the mouse with the hammer in order to earn points and win the game. Approach To design the mouse game, we need to write the code in HTML, CSS, and JavaScript. Step 1 − Firstly, let us look into the HTML part of the code; ...
Read MoreJavaScript: Sort Object of Objects
Suppose we have an Object of Objects like this: const obj = { "CAB": { name: 'CBSSP', position: 2 }, "NSG": { name: 'NNSSP', position: 3 }, "EQU": { name: 'SSP', position: 1 } }; We need to write a JavaScript function that sorts the sub-objects based on the 'position' property in ascending order. Method 1: Using Object.keys() and ...
Read MoreFuzzy Search Algorithm in JavaScript
Fuzzy search allows finding strings that match a pattern even when characters are not consecutive. In JavaScript, we can implement a fuzzy search algorithm that checks if characters from a search query appear in the same order within a target string. How Fuzzy Search Works The algorithm loops through each character of the search query and verifies that all characters exist in the target string in the same sequential order, though they don't need to be adjacent. For example: ('a haystack with a needle').fuzzySearch('hay sucks'); // false ('a haystack with a needle').fuzzySearch('sack hand'); // true ...
Read MoreLongest possible string built from two strings in JavaScript
We need to write a JavaScript function that takes two strings containing only letters from a to z and returns the longest possible sorted string with distinct letters from both strings combined. Problem Statement Given two strings s1 and s2, create a function that: Combines both strings Removes duplicate characters Returns a sorted string containing each unique letter only once Solution Using Array Methods Here's an implementation that combines the strings, removes duplicates, and sorts the result: const str1 = "xyaabbbccccdefww"; const str2 = "xxxxyyyyabklmopq"; const longestPossible = (str1 = '', ...
Read MoreSorting numbers based on their digit sums in JavaScript
We are required to write a JavaScript function that takes in an array of positive integers and sorts them based on their digit sums in descending order. Numbers with higher digit sums appear first. Problem Statement Given an array of positive integers, sort the array so that numbers with the highest digit sum come first, followed by numbers with lesser digit sums. For example, if the input array is: const arr = [5, 34, 1, 13, 76, 8, 78, 101, 57, 565]; The output should be: [565, 78, 76, 57, 8, ...
Read MoreHow to create an Ellipse with dash pattern border using FabricJS?
In this tutorial, we are going to create an ellipse with a dash pattern border using FabricJS. Ellipse is one of the various shapes provided by FabricJS. In order to create an ellipse, we have to create an instance of fabric.Ellipse class and add it to the canvas. We can change the appearance of the dashes of the border, by using the borderDashArray property. However, our ellipse object must have borders in order for this property to work. If the hasBorders property is assigned a false value, this property will not work. Syntax ...
Read MoreHow to create a Textbox with background colour using FabricJS?
In this tutorial, we are going to create a Textbox with background colour using FabricJS. We can customize, stretch or move around the text written in a textbox. We can also customize the text itself by using properties like fontSize, fontFamily, fontStyle, fontWeight etc. In order to create a textbox, we will have to create an instance of fabric.Textbox class and add it to the canvas. The backgroundColor property allows us to assign a colour to our object's background and it is rectangular in shape for the textbox. Syntax new fabric.Textbox(text: String, { backgroundColor: String }: Object) ...
Read MoreWhat is Unary Plus Operator in JavaScript?
The unary plus operator (+) is a JavaScript operator that converts its operand to a number. Unlike binary plus for addition, the unary plus works on a single value and is primarily used for type conversion from non-numeric values to numbers. Syntax +operand Where operand can be any JavaScript value that you want to convert to a number. Using Unary Plus with Numeric Strings The unary plus operator converts string representations of numbers into actual numbers: const x = ...
Read MoreNumber to alphabets in JavaScript
We are required to write a JavaScript function that takes in a string of any variable length that represents a number. Our function is supposed to convert the number string to the corresponding letter string. For example − If the number string is − const str = '78956'; Then the output should be − const output = 'ghief'; If the number string is − const str = '12345'; Then the output string should be − const output = 'lcde'; Notice how we ...
Read More