Articles on Trending Technologies

Technical articles with clear explanations and examples

Finding minimum flips in a binary string using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 264 Views

A monotonically increasing binary string consists of some number of '0's (possibly zero) followed by some number of '1's (also possibly zero). Examples include "000", "111", "0011", or "01". Problem Statement Given a binary string, we need to find the minimum number of flips required to make it monotonically increasing. We can flip any '0' to '1' or any '1' to '0'. For example, with input "00110", we can flip the last '0' to '1' to get "00111", which requires only 1 flip. Approach Using Dynamic Programming We use memoization to track the minimum flips ...

Read More

How to create a canvas with a crosshair cursor using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 523 Views

In this article, we are going to create a canvas with a crosshair cursor using FabricJS. Crosshair is one of the native cursor styles available, which can be used in the FabricJS canvas too. FabricJS provides various types of cursors like default, all-scroll, crosshair, col-resize, row-resize, etc. which are reusing the native cursor under the hood. Each of these cursors look slightly different based on operating system. Syntax new fabric.Canvas(element: HTMLElement|String, { defaultCursor: String }: Object) Parameters element − This parameter is the ...

Read More

How to set the dash pattern of controlling corners of Ellipse using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 237 Views

In this tutorial, we are going to learn how we can implement the dash pattern of controlling corners of Ellipse 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 color to it, changing its size etc. We can also specify a dash pattern for the controlling corners by using the cornerDashArray property. Syntax new fabric.Ellipse({ cornerDashArray: Array }: Object) Parameters ...

Read More

How to create a Triangle with background colour using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 254 Views

In this tutorial, we are going to create a Triangle with background colour using FabricJS. Triangle is one of the various shapes provided by FabricJS. In order to create a triangle, we will have to create an instance of fabric.Triangle class and add it to the canvas. The backgroundColor property allows us to assign a colour to our object's background. It is the colour of the container where the Triangle lives and is rectangular in shape for the triangle. Syntax new fabric.Triangle({ backgroundColor: String }: Object) Parameters ...

Read More

How to set the angle of skew on the Y-axis of a Textbox using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 290 Views

In this tutorial, we are going to learn how to set the angle of skew on the y-axis of 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. Our textbox object can be customized in various ways like changing its dimensions, adding a background color or by changing the angle of skew on the y-axis. We can do this by using the skewY property. Syntax new fabric.Textbox(text: ...

Read More

How to change the font family of IText using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 523 Views

In this tutorial, we are going to learn about how to change the font family of IText object 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 automatically. This is not true for ...

Read More

How to convert JavaScript datetime to MySQL datetime?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 2K+ Views

Date time manipulation in JavaScript is important while dealing with databases. JavaScript Date and time are different from the MySQL date and time. JavaScript provides multiple ways to represent Date and time none of these formats are the same as MySQL's date and time format. In this article, we will discuss some approaches to converting JS date and time into MySQL date and time format. First of all, we will understand the difference between Javascript and MySQL date and time formats. Here is an example − Javascript − ISO 8601 Date Format: YYYY-MM-DDTHH:mm:ss.sssZ MySQL ...

Read More

Check if the elements of the array can be rearranged to form a sequence of numbers or not in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 189 Views

We are required to write a JavaScript function that takes in an array of numbers and checks if the elements of the array can be rearranged to form a sequence of numbers or not. For example: If the array is − const arr = [3, 1, 4, 2, 5]; Then the output should be true because these numbers can be rearranged to form the consecutive sequence: 1, 2, 3, 4, 5. Approach To solve this problem, we need to: Sort the array in ascending order Check if each element is exactly ...

Read More

Flatten array to 1 line in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 292 Views

Suppose, we have a nested array of numbers like this − const arr = [ [ 0, 0, 0, -8.5, 28, 8.5 ], [ 1, 1, -3, 0, 3, 12 ], [ 2, 2, -0.5, 0, 0.5, 5.3 ] ]; We are required to write a JavaScript function that takes in one such nested array of numbers. The function should combine all the numbers in the nested array to form a single string. In the resulting string, the adjacent numbers should be separated by whitespaces and ...

Read More

JavaScript - How to create nested unordered list based on nesting of array?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 3K+ Views

In this tutorial, we'll learn how to create nested unordered lists in HTML using JavaScript. We'll use recursion to traverse nested arrays and generate the corresponding HTML structure dynamically. Understanding the Problem We need to convert a nested array structure into an HTML unordered list where: String elements become list items Array elements become nested sublists The structure preserves the original nesting levels For example: Coffee ...

Read More
Showing 14951–14960 of 61,297 articles
Advertisements