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 are props in react native?
Props are properties that help to modify the React Native component. The component created can be used with different parameters using props concept. With props you can pass information from one component to another and at the same time re-use the component as per your requirement. You will be familiar with props if you are well versed with ReactJS, as the same concepts follow in React Native. Props are read-only and help make components dynamic and reusable. Example 1: Props inside React Native Built-in Components Consider the Image component: The style and ...
Read MoreHow to set the color of a selection area on a canvas using FabricJS?
In this article, we are going to learn how to set the color of a selection area on a canvas using FabricJS. We can adjust the color using the selectionColor property. Syntax new fabric.Canvas(element: HTMLElement|String, { selectionColor: String }: 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 on this element. ...
Read MoreJavaScript: How to check whether an array includes a particular value or not?
In JavaScript, there are several ways to check whether an array includes a particular value. This article explores different approaches to search for values in arrays effectively. Array Creation Syntax let array = [arrayItem1, arrayItem2, arrayItem3, ...]; Using for Loop (Traditional Approach) The traditional approach involves looping through all array elements and comparing each value with the target value. This method also allows you to find the index of the element. Array Value Check ...
Read MoreHow to set the width of stroke of Circle using FabricJS?
In this tutorial, we are going to learn how to set the width of stroke for a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will have to create an instance of fabric.Circle class and add it to the canvas. The strokeWidth property allows us to specify the width of a stroke for an object. Syntax new fabric.Circle({ strokeWidth: Number }) Parameters options (optional) − This parameter is an Object which ...
Read MoreHow to set the opacity of a Rectangle using FabricJS?
In this tutorial, we are going to learn how to set the opacity of Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. We can customize a rectangle object by adding a fill colour to it, eliminate its borders or even make changes in its dimensions. Similarly, we can also change its opacity by using the opacity property. Syntax ...
Read MoreHow to calculate minutes between two dates in JavaScript?
In this article, you will understand how to calculate minutes between two dates in JavaScript. The Date object works with dates and times. Date objects are created with new Date(). To calculate minutes between dates, we convert the time difference from milliseconds to minutes using mathematical operations. Method 1: Using a Function In this example, we create a reusable function to find the time difference in minutes. function minutesDiff(dateTimeValue2, dateTimeValue1) { var differenceValue = (dateTimeValue2.getTime() - dateTimeValue1.getTime()) / 1000; differenceValue /= 60; return Math.abs(Math.round(differenceValue)); } ...
Read MoreShortest syntax to assign properties from function call to an existing object in JavaScript
In JavaScript, you can quickly assign properties from a function call to an existing object using several concise syntaxes. This article explores the most efficient approaches to merge function-returned properties into existing objects. An object in JavaScript is a separate entity having properties and a type. JavaScript objects can have properties that specify their attributes. Using Spread Syntax (...) The spread syntax provides the shortest way to assign properties from a function call to an existing object. It expands an object's properties into a new object, effectively merging them. Syntax existingObject = { ...existingObject, ...
Read MoreCompare arrays using Array.prototype.every() in JavaScript
We are required to write a JavaScript function that takes in two arrays of literals. Then our function should return true if all the elements of first array are included in the second array, irrespective of their count, false otherwise. We have to use Array.prototype.every() method to make these comparisons. Syntax array.every(callback(element, index, array), thisArg) How Array.every() Works The every() { const areEqual = arr1.every(el => { return arr2.includes(el); }); return areEqual; }; ...
Read MoreSum of all prime numbers in JavaScript
In JavaScript, calculating the sum of all prime numbers up to a given limit is a common programming challenge. This involves identifying prime numbers and adding them together efficiently. Understanding Prime Numbers A prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. For example, if we want to find the sum of all prime numbers up to 10, we identify: 2, 3, 5, 7. Their sum is 2 + 3 + 5 + 7 = 17. ...
Read MoreConverting whitespace string to url in JavaScript
In web URLs, browsers automatically replace spaces with '%20' for proper encoding. JavaScript provides multiple methods to convert whitespace characters to URL-encoded format. We need to write a function that takes a string and replaces all whitespace characters with '%20'. For example, if the input string is: const str = 'some extra Space'; Then the output should be: const output = 'some%20extra%20%20Space'; Using Manual Loop Method This approach iterates through each character and manually replaces spaces: const str = 'some extra Space'; const replaceWhitespace = (str = ...
Read More