Articles on Trending Technologies

Technical articles with clear explanations and examples

JavaScript input type=submit is not working?

Disha Verma
Disha Verma
Updated on 15-Mar-2026 2K+ Views

The input type submit is not working is one of the common issues that developers face while working with JavaScript forms. To make it work properly, you need to handle form events correctly or prevent the default browser behavior when necessary. This article examines common reasons why a submit button might not work in JavaScript and provides practical solutions to resolve these issues. Common Reasons for Submit Button Issues The following are some common reasons that may lead to this issue: Missing Event Listener − If you haven't added an event ...

Read More

Do JavaScript arrays have an equivalent of Python’s \"if a in list\"?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 782 Views

JavaScript provides the includes() method as the direct equivalent of Python's if item in list syntax. This method returns true if the element exists in the array, otherwise false. In Python, you check membership using: # Python syntax if "apple" in fruits: print("Found!") JavaScript achieves the same result with the includes() method, which is supported in all modern browsers and provides a clean, readable solution. Syntax array.includes(searchElement, fromIndex) Parameters searchElement − The element to search for in the array fromIndex (optional) − The position ...

Read More

Array of objects to array of arrays in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 957 Views

Converting an array of objects to an array of arrays is a common transformation in JavaScript. This is useful when you need to extract object values into a simpler array format for data processing or visualization. Problem Statement Suppose we have an array of objects like this: const arr = [ {"Date":"2014", "Amount1":90, "Amount2":800}, {"Date":"2015", "Amount1":110, "Amount2":300}, {"Date":"2016", "Amount1":3000, "Amount2":500} ]; We need to transform this into an array of arrays containing the object values: [ ...

Read More

Reversing a string using for loop in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

We are required to write a JavaScript function that takes in a string as the only argument. The function should construct a new reversed string based on the input string using a for loop. Syntax for (let i = string.length - 1; i >= 0; i--) { reversedString += string[i]; } Example Following is the code − const str = 'this is the original string'; const reverseString = (str = '') => { let reverse = ''; const { length: ...

Read More

Sorting binary string having an even decimal value using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 245 Views

We are required to write a JavaScript function that takes in a string containing binary strings of length 3, all separated by spaces. Our function should sort only the even numbers (when converted from binary to decimal) in ascending order, while leaving all odd numbers in their original positions. Problem Given a string with binary numbers, we need to: Convert each binary string to its decimal equivalent Identify which numbers are even Sort only the even numbers in ascending order Keep odd numbers in their original positions Example Let's look at the binary strings ...

Read More

Stream writable.cork() and uncork() Method in Node.js

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

The writable.cork() method is used for forcing all written data to be buffered in memory. This buffered data will only be flushed when stream.uncork() or stream.end() methods are called. These methods are useful for optimizing performance by batching multiple write operations. Syntax cork() writable.cork() uncork() writable.uncork() Parameters Both methods take no parameters. The cork() method buffers subsequent write operations, while uncork() flushes the buffered data to the underlying destination. How It Works When cork() is called, all subsequent write operations are buffered in memory instead of being ...

Read More

How to swap variables using Destructuring Assignment in JavaScript?

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

The Destructuring assignment is a feature that was introduced in the ECMAScript 2015. This feature lets the user extract the contents of the array, and properties of an object into distinct variables without actually writing the repetitive code. This assignment lets the expression unpack values from arrays, and properties into distinct variables. One of the most elegant use cases is swapping variables without using a temporary variable. Traditional Variable Swapping Before destructuring, swapping variables required a temporary variable: Traditional Variable Swap ...

Read More

How to hide the controlling corners of a Rectangle using FabricJS?

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

In this tutorial, we are going to learn how to hide the controlling corners 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. The controlling corners of an object allow us to increase or decrease its scale, stretch or change its position. We can customize our controlling corners in many ways such as adding a specific colour to it, changing their size, ...

Read More

How to set the size of subscript with Text using FabricJS?

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

In this tutorial, we are going to learn how to set the size of subscript with 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, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. We can also use the subscript property where we can specify its size. Syntax new fabric.Text(text: String , { subscript : {"size": Number, "baseline": Number}: ...

Read More

How to set the angle of a Line in FabricJS?

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

In this tutorial, we are going to learn about how to set the angle of a Line object 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 set the angle of a line object we use the angle property. Syntax ...

Read More
Showing 16141–16150 of 61,297 articles
Advertisements