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
What is a typical use case for JavaScript anonymous functions?
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 MoreHow to disable uniform scaling on a canvas using FabricJS?
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 MoreAdding a Carousel to Your Site with Slick.js
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 MoreHow to center an Image object on current viewport of canvas using FabricJS?
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 MoreHow to draw a hexagon with Polygon using FabricJS?
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 MoreHow to transform a JavaScript iterator into an array?
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 MoreNumber prime test in JavaScript by creating a custom function?
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 MoreAlgorithm for matrix multiplication in JavaScript
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 MoreWhat is the "get" keyword before a function in a class - JavaScript?
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 MoreFind the least duplicate items in an array JavaScript
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