Front End Technology Articles

Page 143 of 652

How to Create an Image Element Dynamically using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 13K+ Views

To create an image element dynamically using JavaScript, we can use various approaches based on our use case. We will explore three effective methods in this article with complete examples and step-by-step explanations. Approaches to Create an Image Element Here are the three main approaches to create an image element dynamically using JavaScript: Using createElement() Method Using Image() Constructor Using innerHTML Property Using createElement() Method The createElement() method is the most standard way to create DOM elements dynamically. This approach creates ...

Read More

How to Get Value of Selected Radio Button Using JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 9K+ Views

Getting the value of a selected radio button using JavaScript is essential for forms, surveys, quizzes, and dynamic UI updates. This article demonstrates two reliable approaches to retrieve radio button values programmatically. We'll explore how to get the selected radio button value from a group of radio buttons using the checked property and the FormData constructor. Approaches to Get Value of Selected Radio Button Here are the two main approaches to get the value of a selected radio button using ...

Read More

How to Change the Background Color after Clicking the Button in JavaScript?

Gungi Mahesh
Gungi Mahesh
Updated on 15-Mar-2026 20K+ Views

To change the background color after clicking the button in JavaScript, we are going to discuss two different approaches. We have to perform two simple tasks: adding a click event listener and changing the background color of the document. In this article our task is to understand how to change the background color after clicking the button in JavaScript. Approaches to Change Background Color on Clicking Button Here is a list of approaches to change the background color after clicking the button in JavaScript which we will be discussing in this article with stepwise explanation and complete ...

Read More

JavaScript Program to Find Area of a Circle

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

To find area of a circle using JavaScript, we will be using the simple formula: Area = π × r² where r is the radius and π is a constant value pi. In this article, we are having radius of the circle and our task is to find the area of the circle using JavaScript. r center Area = π × r² Example Calculation let radius = 10 and π(pi) = ...

Read More

JavaScript Program to Find Simple Interest

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

To find simple interest in JavaScript, we calculate the product of principal amount, rate of interest (%), and time period. Simple interest is a quick and easy method to find the interest charge or extra amount paid by a borrower to a lender on a certain amount of principal within a time period. In this article, we are given data for principal, rate, and time. Our task is to write a JavaScript program to find simple interest. Users should be familiar with the formula to calculate simple interest, arithmetic operators in JavaScript, and JavaScript functions. Formula ...

Read More

JavaScript Program for Products of ranges in an array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 312 Views

We will be given an array and we have to answer some queries related to the given range that is from a given starting index to the ending point or index we have to return the product of the elements in that range. We will see some approaches in this article to implement the above problem in JavaScript with the explanation. Introduction to Problem We are given an array and some queries, in each query we will be given some ranges by indicating the first and the last index of the range and we have to answer the ...

Read More

JavaScript program to find maximum element of each row in a matrix

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 593 Views

In JavaScript, the 2D matrix manipulation involves working with arrays of arrays, often to perform operations on rows or columns. In this example, we focus on finding the maximum value in each row of a matrix. Two methods are demonstrated: using nested loops for step-by-step iteration, and using map() with Math.max() for a more concise, functional approach. Both methods return an array of the maximum values from each row, but the map() approach is more efficient and modern. Different Approaches Following are the different approaches to finding maximum element of each row in a matrix − ...

Read More

JavaScript Program to Check if a Given Matrix is Sparse or Not

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 373 Views

To check if a given matrix is sparse or not, we will be discussing two different approaches, their complexities, and example codes. A sparse matrix is a special type of matrix in which the number of zeroes is strictly more than half of the total number of elements present in the given matrix. In this article we are having a 2D matrix, our task is to write a JavaScript program to check if a given matrix is sparse or not. Users must be familiar with conditional statement, nested for loop and javascript methods. Example Input: Matrix: [[1, ...

Read More

Detect Whether a Device is iOS or Not Using JavaScript

Prince Yadav
Prince Yadav
Updated on 15-Mar-2026 18K+ Views

JavaScript is a high-level, interpreted programming language that is widely used for developing dynamic and interactive web applications. Its versatility and ease of use have made it one of the most popular programming languages in the world. In this tutorial, we'll explore how to use JavaScript to detect whether a device is running iOS or not. Knowing the type of device your users are accessing your web application from is crucial as a software developer. This information can be used to provide a better user experience or to customize the layout and functionality of your web application. In this ...

Read More

JavaScript Program for the Last duplicate element in a Sorted Array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 526 Views

In this article, we are going to explore a JavaScript program that works with a sorted array containing duplicate elements. The task is to traverse the array using a loop and identify both the index of the last duplicate element and the duplicate number. Introduction to Problem In the given problem we have to find the last duplicate element in a sorted array. Duplicate means the number is present more than one time. Example − Input arr[] = {1, 2, 2, 3, 5, 5, 6, 7} Output Last index: 5 Last duplicate ...

Read More
Showing 1421–1430 of 6,519 articles
« Prev 1 141 142 143 144 145 652 Next »
Advertisements