Mayank Agarwal

Mayank Agarwal

307 Articles Published

Articles by Mayank Agarwal

Page 2 of 31

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 400 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 621 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 992 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

How to chain asynchronous functions in JavaScript?

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

JavaScript is a single-threaded language that executes operations synchronously by default. Synchronous operations can be time-consuming and block other operations in the thread. JavaScript provides asynchronous programming capabilities that allow functions to execute without blocking other operations. This is achieved through asynchronous constructs like Promises, async/await, and callbacks. Asynchronous functions are powerful, but their unpredictable execution timing can create challenges. Chaining these functions ensures they execute in a specific order, making your code more predictable and easier to debug. In this article, we will explore different methods for chaining asynchronous functions using modern JavaScript features. The ...

Read More

crypto.createDiffieHellman() Method in Node.js

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

The crypto.createDiffieHellman() method in Node.js creates a Diffie-Hellman key exchange object using a specified prime value and an optional generator. This method enables secure key exchange between two parties over an insecure channel. Syntax crypto.createDiffieHellman(prime, [primeEncoding], [generator], [generatorEncoding]) Parameters prime – The prime number used for the Diffie-Hellman exchange. Can be a number (bit length) or Buffer/string containing the prime value. primeEncoding ...

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