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
Accumulating array elements to form new array in JavaScript
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 MoreHow to set the minimum allowed scale value of Rectangle using FabricJS?
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 MoreHow to check if the constructor of an object is a JavaScript Object?
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 MoreWhich Android Browser Has The Best JavaScript Support?
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 MoreHow to append data to element using JavaScript?
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 MoreHow to sort rows in a table using JavaScript?
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 MoreHow to new line string - JavaScript?
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 MoreObject to Map conversion in JavaScript
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 MoreIs uppercase used correctly JavaScript
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 MoreReversing the alphabet from back to front and front to back in JavaScript
In JavaScript, we can create a function that finds the "mirror" position of an alphabet character. Given a letter, we find its position from the start and return the letter at the same position from the end. Understanding the Logic The alphabet has 26 letters. If we split it into two halves, each letter in the first half corresponds to a letter in the second half when reversed. For example, 'a' (1st position) corresponds to 'z' (26th position), 'b' corresponds to 'y', and so on. Example Implementation Here's how we can implement this functionality: ...
Read More