Mayank Agarwal

Mayank Agarwal

307 Articles Published

Articles by Mayank Agarwal

307 articles

How to use the debugger keyword in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 716 Views

Whenever an unexpected occurrence takes place in a JavaScript code, we need to debug it to check the cause. Debugging is a very important aspect of programming that lets you determine why a system or application behaves abnormally. It is a process of testing multiple times with different inputs and finding errors to reduce bugs from computer programs. In this article, we will be exploring the debugger keyword in JavaScript and how to use it. The debugger keyword in JavaScript is a common keyword used in debugging processes and variable inspection. When the debugger keyword is encountered and developer ...

Read More

agent.createConnection() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 849 Views

The agent.createConnection() method is an interface provided by the Node.js http module. This method produces a socket/stream that can be used for HTTP requests. You can override this method in custom agents for greater flexibility. A socket/stream can be returned either directly from this function or by passing it to the callback. Syntax agent.createConnection(options, [callback]) Parameters The above function accepts the following parameters: options – These options contain the connection details for which the stream has to be created. ...

Read More

How to create a chart from JSON data using Fetch API in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 5K+ Views

In this article, we will explore how to create a chart after fetching JSON data using JavaScript's Fetch API. We'll first fetch the data from a remote server, then use that data to create a visual chart using Chart.js library. What is the Fetch API? The Fetch API provides a modern interface for making HTTP requests and handling responses. It returns promises, making it easier to work with asynchronous data compared to older methods like XMLHttpRequest. Syntax const response = fetch(resource [, init]) Parameters resource − The URL ...

Read More

Changing the npm start-script of Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 10K+ Views

The start-script of a Node.js application consists of all the commands that will be used to perform specific tasks. When starting or initializing a Node.js project, there are predefined scripts that will be created for running the application. These scripts can be changed as per the need or demand of the project. Script commands are widely used for making different startup scripts of programs in both Node and React. npm start is used for executing a startup script without typing its execution command. Package.json File Structure The start script needs to be added in the package.json file. ...

Read More

How to Create a Profit and Loss Calculator using HTML, CSS, and JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 2K+ Views

In this article, we are going to create a profit and loss calculator using JavaScript. We will be using basic math formulas to calculate the profit and loss, returning the result in percentage along with the actual values. To calculate profit and loss, we need two values: CP (Cost Price) and SP (Selling Price). Formulas to Calculate Profit and Loss Profit: SP − CP Profit Percentage: (Profit/CP) × 100 Loss: CP − SP Loss Percentage: (Loss/CP) × 100 Creating the Calculator ...

Read More

Creating an Agent in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 1K+ Views

In Node.js, an HTTP Agent manages connection pooling for HTTP client requests. You can create a custom agent using the new Agent() constructor to control connection behavior like keep-alive settings and socket limits. Syntax new http.Agent({options}) Parameters The Agent constructor accepts an options object with the following configurable properties: keepAlive – Keeps sockets open for reuse instead of closing them after each request. Default: false ...

Read More

How to Create a Color Picker using HTML, CSS, and JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 2K+ Views

We can easily create a simple color picker on a palette in JavaScript. The primary colors on a color picker are RGB i.e. Red, Green, and Blue. With the help of mixing these colors, we can form any color we want. In this article, we will be learning about how to get the RGB value from the user and form different colors with the help of CSS using the RGB color properties. The color intensity of RGB ranges from 0 to 255 where 0 is the least intensity and 255 is the highest intensity. When the intensity of ...

Read More

How to enable JavaScript in Chrome, Firefox, and Safari?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 930 Views

JavaScript has become an essential part of modern websites. Nearly every website requires JavaScript support to function properly. All major browsers include a setting to enable or disable JavaScript. When JavaScript is disabled, websites may not work correctly, preventing users from accessing important features and interactive elements. To ensure websites function properly, you need to enable JavaScript in your browser. Here's how to enable JavaScript in the three most popular browsers: Google Chrome Mozilla Firefox Safari Google Chrome Follow these steps to ...

Read More

Logging in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 456 Views

Logging is a very essential part in any application whether it is made in Node.js or any other programming languages. Logging helps us to detect weird behaviours of an application along with real-time errors and exceptions. One should definitely put logical logs in their application. These logs help the user to identify any mistakes and resolve it on urgent basis. There are 5 different log levels which are present at the moment with the user. These log levels are used to define different kinds of logs and helps the user to identify different scenarios. The log levels must be ...

Read More

Difference between addEventListener and on-click in JavaScript

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 1K+ Views

The addEventListener and the onclick event both listen for an event. Both these event methods record an event and execute a function based on that event whenever a button is clicked. Though there is a difference between how both these events work. In this article, we are going to explore the differences between the addEventListener and the onclick function in JavaScript. addEventListener Method The addEventListener method uses an event handler to attach it to the specified element. This method is more flexible and allows multiple event listeners on the same element. Syntax element.addEventListener(event, listener, ...

Read More
Showing 1–10 of 307 articles
« Prev 1 2 3 4 5 31 Next »
Advertisements