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
How to create a canvas with Circle using FabricJS?
In this tutorial, we are going to learn about how to create a canvas with a Circle object using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will have to create an instance of fabric.Circle class and add it to the canvas. Syntax new fabric.Circle({ radius: Number }: Object) Parameters options (optional) − This parameter is an Object which provides additional customizations to our object. Using this parameter, properties such as colour, cursor, ...
Read MoreHow to Access element from Table using JavaScript?
To access table elements using JavaScript, you can use methods like document.getElementById() or document.getElementsByTagName() to select the table, then access individual rows and cells. This article demonstrates how to access table rows and create an interactive hover effect. Basic Table Access Methods JavaScript provides several ways to access table elements: By ID: document.getElementById('tableId') - Access a specific table By Tag Name: document.getElementsByTagName('tr') - Access all table rows Table Properties: Use table.rows or table.childNodes to access rows Example: Interactive Table with Hover Effect Let's create a table where rows highlight when you hover over ...
Read MoreConverting two arrays into a JSON object in JavaScript
Given two arrays and the task is to convert those two arrays into a JSON object. Where the first array elements are keys of the object and the second array elements are values of the object. Input-Output Scenario Let's look into the scenario of how two arrays will be converted into a JSON object. Consider two arrays are having some elements. Now, we need to convert these two arrays into a JSON object. Array1 = [1, 2, 3, 4]; Array2 = ['A', 'B', 'C', 'D']; Output = {"1":"A", "2":"B", "3":"C", "4":"D"} //JSON object ...
Read MoreFinding Common Item Between Arbitrary Number of Arrays in JavaScript
Finding common elements among multiple arrays is a frequent requirement in JavaScript programming. This problem involves identifying elements that appear in every array within a collection of arrays. What are Arbitrary Number of Arrays An arbitrary number of arrays refers to any collection of multiple arrays (more than two) where we need to find intersection elements. These arrays can contain random elements and are typically organized as an array of arrays or nested data structure. // Example: Array of arrays const arrayCollection = [ [1, 2, 3, 4], [2, 3, 5, 6], ...
Read MoreFunction to find out palindrome strings JavaScript
In this problem statement, our aim is to create a function to find out that the given string is palindrome with the help of Javascript functionalities. So for solving this problem first we need to understand the problem in simple terms. Understanding the Problem Statement We have given a string as an input string and our main aim is to check if the string is a palindrome string or not. If it is palindrome then return true otherwise return false. What is a Palindrome? A palindrome is a string that reads the same forwards and backwards. ...
Read MoreCalculating h index of a citation in JavaScript
The h-index is a metric used to measure both the productivity and citation impact of a researcher. In JavaScript, we can calculate it by analyzing an array of citation counts for a researcher's papers. What is H-Index? A researcher has h-index of value h if they have h papers with at least h citations each, and the remaining papers have no more than h citations each. For example, if a researcher has papers with citations [1, 6, 3, 0, 5], they have 3 papers with at least 3 citations (papers with 6, 3, and 5 citations), so the ...
Read MoreIs the reversed number a prime number in JavaScript
We are required to write a JavaScript function that takes in a number and returns true if the reverse of that number is a prime number, false otherwise. Problem Understanding To solve this problem, we need two helper functions: A function to reverse the digits of a number A function to check if a number is prime Solution Implementation Here's the complete solution with helper functions: const num = 13; const findReverse = (num) => { return +num .toString() .split('') .reverse() .join(''); }; const isPrime = (num) => { if (num
Read MoreHow to create a Circle with a background colour using FabricJS?
In this tutorial, we are going to create a Circle with background colour using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we have to create an instance of fabric.Circle class and add it to the canvas. The backgroundColor property allows us to assign a colour to our object's background. It is the colour of the container (where the circle lives) which is square in shape. Syntax new fabric.Circle({ backgroundColor: String }: Object) Parameters ...
Read MoreReversing the even length words of a string in JavaScript
We are required to write a JavaScript function that takes in a string and reverses the words in the string that have an even number of characters in them. Let's say the following is our string: const str = 'This is an example string'; We want to reverse the even length words of the above string i.e. reverse the following words: This (4 characters) is (2 characters) an (2 characters) string (6 characters) The word "example" has 7 characters (odd length), so it remains unchanged. Syntax ...
Read MoreUsing one array to help filter the other in JavaScript
When working with arrays of objects, you often need to filter one array based on values from another array. This is a common requirement when you have a list of items and want to keep only those that match specific criteria. Problem Statement Given an array of objects and an array of values, we need to filter the objects array to include only those objects whose property matches values in the second array. Sample Data Let's start with these arrays: const main = [ {name: "Karan", age: 34}, {name: "Aayush", ...
Read More