Mayank Agarwal

Mayank Agarwal

307 Articles Published

Articles by Mayank Agarwal

Page 2 of 31

Logging in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 470 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

Difference Between Static and Const in JavaScript

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

Static variables can be defined as a class property that is used in a class and not on the class instance. This type of variable is stored in the data segment area of the memory. The value assigned to these types of variables is shared among every instance that is created in the class. We need to use the static keyword for creating any static entity like a static variable, static function, operators, properties, etc. The value of a static variable is set at the runtime of the application and serves as a global value for the whole application. ...

Read More

How to access HTML elements in JavaScript?

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

In JavaScript, accessing HTML elements is fundamental for creating dynamic web pages. The Document Object Model (DOM) provides several methods to select and manipulate HTML elements based on different criteria. Get HTML element by Id Get HTML element by className Get HTML element by Name Get HTML element by tagName Get HTML element by CSS Selector Get HTML element by Id The getElementById() method retrieves a single element using its unique ID attribute. This is the most efficient way to ...

Read More

How does asynchronous code work in JavaScript?

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

In this article, we will be exploring how async code actually works in JavaScript, how it is initialized, and how it is executed and called. But before moving on let's look at what is synchronous code and how it is different from asynchronous code. Synchronous Code − Code executes line by line in order. Each operation must complete before the next one starts. The program waits for each task to finish. Asynchronous Code − ...

Read More

How does JavaScript work behind the scene?

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

JavaScript is a powerful language that has revolutionized frontend development. Understanding how JavaScript works behind the scenes is crucial for writing efficient code and debugging effectively. JavaScript is a synchronous, single-threaded language that executes code in a specific order. Everything in JavaScript runs inside an Execution Context, which is the environment where code is executed. What is an Execution Context? The Execution Context consists of two main components: Memory Component ...

Read More

How to Add Google Maps to a Website?

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

In this article, we will be exploring Google Maps and how to add or embed google maps into our HTML template/website. Once the Google Maps are embedded into the website we can pin a location in it to display the user the current position of the store or a company. Steps to Embed Google Maps Below are the steps that need to be followed to embed Google Maps into your HTML pages: We need to generate an API key to be able to use Google maps privately. Creating the HTML ...

Read More

How to add HTML elements dynamically using JavaScript?

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

Adding HTML elements dynamically with JavaScript allows you to modify page content in real-time based on user interactions. This technique is essential for creating interactive web applications and dynamic user interfaces. Approach Create a simple HTML page with a container element where new content will be added Define the HTML structure you want to add dynamically Use JavaScript to listen for user events (like button clicks) Dynamically insert new HTML elements using DOM manipulation methods Style the elements with CSS to maintain ...

Read More

How to call a JavaScript function in HTML?

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

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 More

How to call the constructor of a parent class in JavaScript?

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

In JavaScript, when working with inheritance, you often need to call the parent class constructor from the child class. This is accomplished using the super() method, which provides access to the parent's constructor and methods. What is a Constructor? A constructor is a special method that runs when creating a new instance of a class. It's used to initialize object properties and set up the object's initial state. In JavaScript, constructors are defined using the constructor keyword within a class. Inheritance in JavaScript Inheritance allows objects to access properties and methods from parent objects. Child classes ...

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