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
Javascript Articles
Page 32 of 534
How to Convert CSV File to JSON in JavaScript?
CSV (Comma-Separated Values) and JSON (JavaScript Object Notation) are two popular data formats. CSV is ideal for tabular data storage, while JSON is widely used in web applications. Converting CSV to JSON in JavaScript is a common requirement when working with data manipulation and API integrations. Understanding CSV and JSON Formats CSV Format: Data is stored in rows with values separated by commas. Each row represents a record, and the first row typically contains column headers. name, age, city Pankaj, 20, Surat Neeraj, 18, Raipur JSON Format: Data is represented as an array of ...
Read MoreHow to Create Protected Object Properties in JavaScript?
JavaScript does not have built-in access modifiers like other languages, but we can create protected object properties using closures and WeakMap. Protected properties are accessible only through specific methods and cannot be directly accessed from outside the object, providing encapsulation and data security. Approaches to Create Protected Object Properties Using Closures Using WeakMap Using Private Fields (ES2022) Using Closures Closures create a private scope where variables are accessible only to inner functions, effectively protecting properties from external access. function ProtectedObject(name, age) ...
Read MoreHow to Convert JSON to ArrayBuffer in JavaScript?
In JavaScript, an ArrayBuffer is a kind of binary structure that enables the manipulation of raw binary data. While JSON represents data as strings, it is sometimes useful to convert JSON into an ArrayBuffer when working with binary APIs or when you need to optimize data transmission. In this article, we will explore two common methods for converting JSON objects into ArrayBuffers in JavaScript. Approaches to Convert JSON to ArrayBuffer Using TextEncoder: Suitable for UTF-8 encoding (recommended). Manual Conversion with DataView: Useful for handling specific binary encoding formats or custom ...
Read MoreHow to Create an Image Element Dynamically using JavaScript?
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 MoreHow to Get Value of Selected Radio Button Using JavaScript?
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 MoreHow to Change the Background Color after Clicking the Button in JavaScript?
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 MoreJavaScript Program to Find Area of a Circle
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 MoreJavaScript Program to Find Simple Interest
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 MoreJavaScript Program for Products of ranges in an array
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 MoreJavaScript program to find maximum element of each row in a matrix
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