Articles on Trending Technologies

Technical articles with clear explanations and examples

What is a typical use case for JavaScript anonymous functions?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 531 Views

In this article, we are going to explore the anonymous functions in JavaScript and their typical use cases. An anonymous function is a function without a name that can be stored in variables, passed as arguments, or used as return values. Anonymous functions are incredibly useful in JavaScript for callbacks, event handlers, functional programming methods like map(), filter(), and situations where you need a function only once. Syntax // Function expression let variable = function() { // code here }; // Arrow function (ES6) let variable = () => { ...

Read More

How to disable uniform scaling on a canvas using FabricJS?

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

In this article, we are going to learn about how to disable uniform scaling in canvas using FabricJS. In FabricJS, an object gets transformed proportionally when dragged from the corners. However, we can disable this behavior by using the uniformScaling property. Syntax new fabric.Canvas(element: HTMLElement|String, { uniformScaling: Boolean }: Object) Parameters element − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized ...

Read More

Adding a Carousel to Your Site with Slick.js

Mukul Latiyan
Mukul Latiyan
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we will demonstrate how to use Slick.js to create responsive carousels for your websites. We'll start with a basic image carousel and then explore various customization options to enhance its functionality. If you try to create a carousel without using any libraries, it will be quite time-consuming. To reduce the effort and add multiple types of carousels with different properties, you can use Slick.js. Slick.js is a widely used jQuery plugin that allows us to create responsive carousels with multiple attributes and different properties. Features of Slick.js There are multiple reasons why Slick.js ...

Read More

How to center an Image object on current viewport of canvas using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we are going to learn how to center an Image object on current viewport of canvas 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 center an Image object on the current viewport of canvas, we use the viewportCenter method. Syntax viewportCenter(): fabric.Object This method centers the object within the current viewport of the canvas both horizontally and vertically. It returns ...

Read More

How to draw a hexagon with Polygon using FabricJS?

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

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. Syntax new fabric.Polygon( points: Array, options: Object ) Parameters points − This parameter accepts an Array which denotes the array of points that make up the polygon object. options (optional) − This parameter ...

Read More

How to transform a JavaScript iterator into an array?

Mohit Panchasara
Mohit Panchasara
Updated on 15-Mar-2026 2K+ Views

In JavaScript, iterators are objects that implement the iterator protocol, allowing you to traverse through collections like Sets, Maps, or custom iterables. Unlike arrays, you cannot access iterator elements by index, so converting iterators to arrays is often necessary for easier manipulation. Here are three effective methods to transform JavaScript iterators into arrays. Using the for-of Loop The for-of loop iterates through each element of an iterator. Inside the loop, you can access elements and push them to an array using the push() method. Syntax for (let element of iterator) { ...

Read More

Number prime test in JavaScript by creating a custom function?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 222 Views

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In JavaScript, we can create a custom function to check if a number is prime. Basic Prime Number Function Here's a simple approach to check if a number is prime: function checkNumberIsPrime(number) { if (number

Read More

Algorithm for matrix multiplication in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

Matrix multiplication is a fundamental operation in linear algebra where two matrices are multiplied to produce a third matrix. In JavaScript, we can implement this algorithm using nested loops to calculate the dot product of rows and columns. Matrix Multiplication Rules For matrix multiplication to be valid, the number of columns in the first matrix must equal the number of rows in the second matrix. If matrix A is m×n and matrix B is n×p, the result will be an m×p matrix. Matrix A (m×n) ...

Read More

What is the "get" keyword before a function in a class - JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 511 Views

The get keyword in JavaScript creates a getter method that allows you to access a function like a property. When you call the getter, it executes the function and returns its value without using parentheses. Syntax class ClassName { get propertyName() { // return some value } } Basic Example Here's how to define and use a getter method: class Employee { constructor(name) { ...

Read More

Find the least duplicate items in an array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 483 Views

We are required to write a JavaScript function that takes in an array of literals which may contain some duplicate values. The function should return an array of all those elements that are repeated for the least number of times. For example− If the input array is − const arr = [1, 1, 2, 2, 3, 3, 3]; Then the output should be − const output = [1, 2]; because 1 and 2 are repeated for the least number of times (2) Example const arr = [1, ...

Read More
Showing 16591–16600 of 61,297 articles
Advertisements