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
Returning reverse array of integers using JavaScript
In JavaScript, creating an array of integers in reverse order (from a number down to 1) is a common programming task. This article explores multiple approaches to generate descending arrays efficiently, from basic loops to built-in array methods. Problem Statement Create a JavaScript function that generates an array of natural numbers starting from a given number and descending down to 1. Sample Input: const num = 5; Sample Output: const output = [5, 4, 3, 2, 1]; Method 1: Using For Loop The most straightforward approach uses a decrementing for ...
Read MoreCalculating value of a sequence based on some input using JavaScript
Problem We need to write a JavaScript function that takes a number n as input and calculates the value of a sequence term un. Given a sequence where: u1 = 0 and u2 = 2 Our function should find the value of un for which the following recurrence relation holds: 6unun+1 - 5unun+2 + un+1un+2 = 0 Understanding the Sequence From the recurrence relation, we can derive that this sequence follows the pattern un = 2n-1 for n ≥ 2, and u1 = 0. Example Implementation Here's the ...
Read Morecrypto.createHash() Method in Node.js
The crypto.createHash() method creates a hash object that can generate hash digests using cryptographic algorithms like SHA-256, MD5, or SHA-512. It's commonly used for password hashing, data integrity verification, and digital signatures. Syntax crypto.createHash(algorithm, [options]) Parameters algorithm – The hashing algorithm to use (string). Common values: 'sha256', 'md5', 'sha512', 'sha1' options – Optional parameters for controlling stream behavior and output length for certain algorithms Return Value Returns a Hash object that can be used to generate hash digests by chaining update() and digest() methods. Example 1: Basic Hash Generation ...
Read MoreHow to add styling or css to your app using reactnative?
React Native provides two main approaches for styling your components: using the StyleSheet component and inline styles. Both methods allow you to apply CSS-like properties to create visually appealing mobile applications. Using StyleSheet Component The StyleSheet component is the recommended approach for styling in React Native. It provides better performance and code organization compared to inline styles. Import StyleSheet First, import the StyleSheet component from React Native: import { StyleSheet } from 'react-native'; Creating Styles Create your styles using StyleSheet.create() method: const styles = StyleSheet.create({ container: { ...
Read MoreHow to set the width of a selection area border on a canvas using FabricJS?
In this article, we are going to learn how to set the width of a selection area border on a canvas using FabricJS. A selection area indicates the area selected using the mouse and all objects under that area will get selected. FabricJS allows us to adjust the width of the selection area border with the selectionLineWidth property. Syntax new fabric.Canvas(element: HTMLElement|String, { selectionLineWidth: Number }: Object) Parameters element − This parameter is the element itself which can be derived using document.getElementById() ...
Read MoreHow to compile a Typescript file?
In this article we are going to explore TypeScript and how to compile and execute TypeScript files. TypeScript is an open-source programming language developed and maintained by Microsoft. TypeScript is syntactically similar to JavaScript but adds additional features like static typing and object-oriented programming. Unlike JavaScript, TypeScript does not run directly in web browsers and must be compiled to JavaScript first. TypeScript files need to be transpiled to JavaScript before they can be executed. This compilation process converts TypeScript syntax into standard JavaScript that browsers and Node.js can understand. Prerequisites Before compiling TypeScript files, you need ...
Read MoreHow to set the padding of a Rectangle using FabricJS?
In this tutorial, we are going to learn how to set the padding of a 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. Just as we can specify the position, colour, opacity and dimension of a rectangle object in the canvas, we can also set the padding of a rectangle object. This can be done by using the padding property. Syntax new fabric.Rect({ padding : Number }: Object) ...
Read MoreHow to get the SVG representation of a Line using FabricJS?
In this article, we are going to learn about how to get the SVG representation of a Line using FabricJS. A Line element is one of the basic elements provided in FabricJS. It is used for creating straight lines. Because line elements are geometrically one-dimensional and do not contain an interior, they are never filled. We can create a line object by creating an instance of fabric.Line, specifying the x and y coordinates of the line and adding it to the canvas. In order to get the SVG representation of a Line object, we use the _toSVG method. Syntax ...
Read MoreHow to use Checkbox inside Select Option using JavaScript?
Sometimes, we require to use the checkbox inside the select option. We can allow users to select multiple options by introducing the checkboxes with the select option. However, if we use the multiple attributes with the tag, it allows us to select them by pressing the 'ctrl + left click', but it is a bad UX. So, we can introduce the checkbox inside the menu to improve the user experience. Here, we will use JavaScript to manage the values of the checked checkboxes in the custom menu. Create a Custom Select Menu The ...
Read MoreIs there any way to check if there is a null value in an object or array in JavaScript?
Null values can be tricky to work with in JavaScript, but they are an important part of the language. In this article, we will discuss various ways you can check if there is a null value in an object or array in JavaScript. The null values display that no object value is present. It is intentionally set to show that a variable has been declared but has not yet been given a value. The primitive value is undefined, which is an unintended absence of any object value, which is comparable to null, that contrasts with the former. This ...
Read More