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
Web Development Articles
Page 276 of 801
Difference between addEventListener and on-click in JavaScript
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 MoreDifference Between Static and Const in JavaScript
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 MoreHow does asynchronous code work in JavaScript?
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 MoreHow does JavaScript work behind the scene?
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 MoreHow to Add Google Maps to a Website?
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 MoreHow to add HTML elements dynamically using JavaScript?
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 MoreHow to call a JavaScript function in HTML?
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 MoreHow to call the constructor of a parent class in JavaScript?
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 MoreHow to chain asynchronous functions in JavaScript?
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 MoreJavaScript: How to check whether an array includes a particular value or not?
In JavaScript, there are several ways to check whether an array includes a particular value. This article explores different approaches to search for values in arrays effectively. Array Creation Syntax let array = [arrayItem1, arrayItem2, arrayItem3, ...]; Using for Loop (Traditional Approach) The traditional approach involves looping through all array elements and comparing each value with the target value. This method also allows you to find the index of the element. Array Value Check ...
Read More