Articles on Trending Technologies

Technical articles with clear explanations and examples

Returning reverse array of integers using JavaScript

Aayush Mohan Sinha
Aayush Mohan Sinha
Updated on 15-Mar-2026 274 Views

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 More

Calculating value of a sequence based on some input using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 194 Views

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 More

crypto.createHash() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 3K+ Views

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 More

How to add styling or css to your app using reactnative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 363 Views

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 More

How to set the width of a selection area border on a canvas using FabricJS?

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

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 More

How to compile a Typescript file?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 2K+ Views

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 More

How to set the padding of a Rectangle using FabricJS?

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

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 More

How to get the SVG representation of a Line using FabricJS?

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

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 More

How to use Checkbox inside Select Option using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 9K+ Views

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 More

Is there any way to check if there is a null value in an object or array in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 9K+ Views

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
Showing 15731–15740 of 61,297 articles
Advertisements