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
JavaScript subtraction of two float values?
JavaScript floating-point arithmetic can produce unexpected results due to precision limitations. To correctly subtract two float values and get accurate results, use parseFloat() to ensure proper number conversion and toFixed() to control decimal precision. The Problem with Float Subtraction Direct subtraction of floats can yield imprecise results: var result1 = 0.3 - 0.1; var result2 = 0.2 - 0.1; document.write("0.3 - 0.1 = " + result1 + ""); ...
Read MoreCreate a to-do list with JavaScript
A TODO list is a simple application that helps users keep track of tasks they need to complete. It typically allows users to add new tasks, mark them as completed, edit existing tasks, and delete unnecessary ones. In this tutorial, we'll learn how to create a functional to-do list using JavaScript. Our to-do list will support the following core features: Add new tasks Delete tasks Mark tasks as completed Edit existing tasks Basic To-Do List Implementation Let's start with a simple example ...
Read MoreHow to form a two-dimensional array with given width (columns) and height (rows) in JavaScript ?
We are required to write a JavaScript function that takes in three arguments: height --> no. of rows of the array width --> no. of columns of the array val --> initial value of each element of the array Then the function should return the new array formed based on these criteria. Method 1: Using Array.apply() with map() This approach creates arrays using Array.apply() and fills them with map(): const rows = 4, cols = 5, val = 'Example'; const fillArray = (width, height, value) => { ...
Read MoreFibonacci like sequence in JavaScript
In JavaScript, you can generate a Fibonacci-like sequence using various approaches including loops and recursion. The Fibonacci sequence is fundamental in programming and demonstrates different algorithmic techniques. What is the Fibonacci Sequence? The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding numbers. The sequence starts with 0 and 1, then continues as: 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. Formula: F(n) = F(n-1) + F(n-2), where F(0) = 0 and F(1) = 1 Method 1: Generate Fibonacci Up to a Certain Number ...
Read MoreFinding average of n top marks of each student in JavaScript
Suppose, we have an array of objects that contains information about some students and the marks scored by them over a period of time like this: const marks = [ { id: 231, score: 34 }, { id: 233, score: 37 }, { id: 231, score: 31 }, { id: 233, score: 39 }, { id: 231, score: 44 }, { id: 233, score: 41 }, { id: 231, score: ...
Read MoreFinding longest consecutive joins in JavaScript
We are required to write a JavaScript function that takes in an array of pairs of numbers, arr, as the first and the only argument. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) that can follow another pair (a, b) if and only if b < c. Chain of pairs can be formed in this fashion. Our function is supposed to find the length longest chain which can be formed. Problem Example For example, if the input to the function is: const arr ...
Read MoreList the important core components of React Native
React Native provides core components that map to native platform views. These components are essential building blocks for creating cross-platform mobile applications. Core Components Overview React Native Component Android Native View iOS Native View Web Browser Description ...
Read MoreHow to call a JavaScript function in HTML?
In this article, we will explore how to call and initialize JavaScript functions from HTML templates. JavaScript functions allow us to execute desired operations and respond to user interactions on web pages. There are several ways to call JavaScript functions in HTML. We'll discuss the most common approaches with practical examples. Using Event Handlers (onclick) The most common way to call JavaScript functions is through event handlers like onclick. When a user interacts with HTML elements (buttons, links, etc.), the associated JavaScript function executes. JavaScript Function Call Example ...
Read MoreHow to set the radius of a Circle using FabricJS?
In this tutorial, we are going to learn how to set the radius of a Circle using FabricJS. We can specify the position, colour, opacity and dimension of a circle object in the canvas, but first we will have to specify a radius for our circle to show up. This can be done by using the radius property. Syntax new fabric.Circle({ radius: Number }: Object) Parameters options (optional) − This parameter is an Object which provides additional customizations to our circle. Using this ...
Read MoreHow to set the vertical scale factor of a Triangle using FabricJS?
In this tutorial, we are going to learn how to set the vertical scale factor of a Triangle using FabricJS. Triangle is one of the various shapes provided by FabricJS. In order to create a triangle, we will have to create an instance of fabric.Triangle class and add it to the canvas. Just as we can specify the position, colour, opacity and dimension of a triangle object in the canvas, we can also set the vertical scale of a triangle object. This can be done by using the scaleY property. Syntax new fabric.Triangle({ scaleY : Number ...
Read More