Implement a custom function similar to Array.prototype.includes() method using JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

1K+ Views

We need to create a custom JavaScript function that mimics the behavior of Array.prototype.includes(). This function should check if a value exists in an array and return a boolean result. Problem We are required to write a JavaScript function that lives on the prototype object of Array. It must take in a literal value, and return true if that value is present in the array it is being called upon, false otherwise. Basic Implementation Here's a simple implementation using a for loop to iterate through the array: const arr = [1, 2, 3, 4, ... Read More

Accumulating array elements to form new array in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

344 Views

We are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument and a number, num, (num ≤ length of array) as the second argument. Our function should add up each contiguous subarray of length num of the array arr to form corresponding elements of new array and finally return that new array. Problem Example For example, if the input to the function is: const arr = [1, 2, 3, 4, 5, 6]; const num = 2; Then the output should be: [3, ... Read More

How to set the minimum allowed scale value of Rectangle using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

235 Views

In this tutorial, we are going to learn how to set the minimum allowed scale 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 set its minimum allowed scale by using the minScaleLimit property. Syntax new fabric.Rect({ minScaleLimit : Number }: Object) ... Read More

How to check if the constructor of an object is a JavaScript Object?

Prince Varshney
Updated on 15-Mar-2026 23:19:00

1K+ Views

In this article, we will check whether the constructor of an object is a JavaScript Object. The constructor property of any JavaScript variable returns a reference to the Object constructor function that created the instance object. The value of this property is a reference to the function itself. All objects have the constructor property, and objects created without an explicit constructor function will have a constructor property that points to the fundamental Object constructor type for that object. To check whether the constructor of a provided value is an Object created by the object constructor function, we need ... Read More

Which Android Browser Has The Best JavaScript Support?

Rushi Javiya
Updated on 15-Mar-2026 23:19:00

2K+ Views

In this tutorial, we explore which Android browser provides the best JavaScript support for developers and users. Most modern browsers support JavaScript due to its popularity and essential role in web development. Android browsers have evolved significantly to provide comprehensive JavaScript support, making mobile web development more powerful and consistent with desktop experiences. The leading browsers with excellent JavaScript support include Chrome, Firefox, Safari, Opera, and Edge. On Android devices, Chrome serves as the primary browser that most developers rely on for testing and development. Before testing JavaScript functionality, ensure that JavaScript is enabled in your browser ... Read More

How to append data to element using JavaScript?

AmitDiwan
Updated on 15-Mar-2026 23:19:00

23K+ Views

We can append data to an HTML element using JavaScript through several methods. The most common approaches include using the innerHTML property, appendChild() method, and the modern append() method. What is Element Appending? Appending data to an element means adding new content to the end of an element's existing content without replacing what's already there. This is essential for dynamic web applications where content needs to be added based on user interactions or data updates. Method 1: Using innerHTML Property The innerHTML property allows you to add HTML content as a string: ... Read More

How to sort rows in a table using JavaScript?

Rushi Javiya
Updated on 15-Mar-2026 23:19:00

2K+ Views

We can't use the built-in sort() method of JavaScript to sort the table rows based on the particular column. So, we need to create a custom algorithm to sort table rows. In this tutorial, we will learn to sort tables and rows using JavaScript. Here, we will look at different examples to sort table rows in ascending and descending order. Syntax Users can follow the syntax below to sort rows in a table using JavaScript. var switchContinue = true; while (switchContinue) { switchContinue = false; var allRows = table.rows; ... Read More

How to new line string - JavaScript?

AmitDiwan
Updated on 15-Mar-2026 23:19:00

730 Views

In JavaScript, there are several ways to create new lines in strings depending on where the output will be displayed. For HTML content, use tags, while for console output or plain text, use the escape sequence . Using Tag for HTML Display When displaying text in HTML elements, use the tag to create line breaks: New Line in HTML Original Text ... Read More

Object to Map conversion in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

248 Views

In JavaScript, you can convert an object to a Map using several approaches. Maps offer advantages over objects like guaranteed key insertion order and the ability to use any data type as keys. Suppose we have an object like this: const obj = { name: "Jai", age: 32, occupation: "Software Engineer", address: "Dhindosh, Maharashtra", salary: "146000" }; We need to convert this object into a Map while preserving all key-value pairs. Using Object.entries() (Recommended) The most concise approach uses Object.entries() with the Map ... Read More

Is uppercase used correctly JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

134 Views

In JavaScript, we can determine whether a string follows correct uppercase usage based on three specific rules. A string is considered to have correct uppercase usage if it meets any of these criteria: All letters in a word are capitals, like "INDIA". All letters in a word are not capitals, like "example". Only the first letter in a word is capital, like "Ramesh". We need to write a JavaScript function that takes a string and determines whether it complies with any of these three ... Read More

Advertisements