Articles on Trending Technologies

Technical articles with clear explanations and examples

Setting a default variable value to undefined in a function - JavaScript?

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

The task we are going to perform in this article is setting a default variable value to undefined in a function. Before we jump into the article, let's understand what are functions in JavaScript. One of the core components of JavaScript are functions. In JavaScript, a function is comparable to a procedure-a collection of statements that carry out an action or compute a value. However, in order for a process to be considered a function, it must accept an input and produce an output with an evident connection between the input and the result. Let's see how to ...

Read More

How to make Ulam number sequence in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 201 Views

A mathematician Ulam proposed generating a sequence of numbers from any positive integer n (n>0) as follows: If n is 1, it will stop. if n is even, the next number is n/2. if n is odd, the next number is 3 * n + 1. continue with the process until reaching 1. This sequence is also known as the Collatz conjecture or 3n+1 problem. It's conjectured that all positive integers eventually reach 1 following these rules. Example Sequences Here are some examples for the first few integers: 2→1 3→10→5→16→8→4→2→1 4→2→1 6→3→10→5→16→8→4→2→1 ...

Read More

JSON group object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 890 Views

In JavaScript, grouping JSON objects means organizing data by common properties or categories. This is useful for data analysis, filtering, and creating structured reports from collections of objects. What is JSON? JSON (JavaScript Object Notation) is a lightweight data format for transferring data between devices. JSON objects use key-value pairs where keys are strings and values can be strings, numbers, booleans, arrays, or nested objects. For example: {"name": "Alice", "age": 25}. const jsonData = [ { team: 'TeamA', score: 20 }, { ...

Read More

How to split sentence into blocks of fixed length without breaking words in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 2K+ Views

In JavaScript, splitting a sentence into blocks of fixed length while keeping words intact requires careful handling of word boundaries. This ensures readability by avoiding broken words across blocks. Understanding the Problem We need to split a sentence into chunks of a specified maximum length without breaking words. Each block should contain complete words only, and if adding a word would exceed the length limit, that word starts a new block. For example, with the sentence "You are reading this article on Tutorials point website" and block length 15, the output should be: ['You are ...

Read More

Validating a square in a 2-D plane in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 217 Views

We are required to write a JavaScript function that takes in four arguments. The four arguments will all be arrays of exactly two numbers representing the coordinates of four vertices of a quadrilateral or any figure (closed or unclosed) on a plane. The task of our function is to determine whether or not the four vertices form a square. If they do form a square, we should return true, false otherwise. Understanding the Problem A square has specific properties: All four sides are equal in length All four angles ...

Read More

Total number of longest increasing sequences in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 904 Views

Finding the total number of longest increasing subsequences (LIS) is a dynamic programming problem. We need to find all subsequences with the maximum possible length where each element is greater than the previous one. Problem We are required to write a JavaScript function that takes in an array of numbers, arr, as the first and the only argument. Our function is required to find the number of longest increasing subsequences (contiguous or non-contiguous). For example, if the input to the function is: const arr = [2, 4, 6, 5, 8]; The output ...

Read More

How does asynchronous code work in JavaScript?

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

In this article, we will be exploring how async code actually works in JavaScript, how it is initialized, and how it is executed and called. But before moving on let's look at what is synchronous code and how it is different from asynchronous code. Synchronous Code − Code executes line by line in order. Each operation must complete before the next one starts. The program waits for each task to finish. Asynchronous Code − ...

Read More

How to set the colour of controlling corners of a Rectangle using FabricJS?

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

In this tutorial, we are going to set the colour of the controlling corners of Rectangle using FabricJS. The cornerColor property allows us to manipulate the colour of the controlling corners when the object is active. Syntax new fabric.Rect({ cornerColor: String }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations to our rectangle. Using this parameter, properties such as colour, cursor, stroke width and a lot of other properties can be changed related to the object of ...

Read More

How to get an object containing parameters of current URL in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 2K+ Views

JavaScript provides several ways to extract URL parameters from the current page or any URL. This is useful for handling query strings, routing, and dynamic content based on URL parameters. Using the Location Object The easiest way to get information about the current URL is to use the Location object. This object is a property of the window object and contains information about the current URL. // Get the entire URL var ...

Read More

How to compute the height of a character at given position in Text using FabricJS?

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

In this tutorial, we are going to learn how to compute the height of a line at a specific line index in Text using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, and line height which can be obtained by the properties textAlign, underline and lineHeight respectively. We can also compute the height of a line at a required line index by using the getHeightOfLine method. Syntax ...

Read More
Showing 15601–15610 of 61,297 articles
Advertisements