What is Asynchronous JavaScript?

In general Asynchronous JavaScript lets the code execute immediately without blocking. For the purpose of understanding this concept let us assume that we have two statements in sequential order in a code. While the first statement being executed, the second one will wait for it to finish. It is known as synchronous execution. On the other hand, if the …

Callback Functions in JavaScript

Basically, Callback Functions in JavaScript provide us a way to pass a function as a parameter to another function. In fact, callback functions are very useful in performing asynchronous operations and registering an event listener. Examples of Callback Functions in JavaScript As an illustration, the following is an example of a simple callback function that …

Arrow Functions in JavaScript

Basically, Arrow Functions in JavaScript provide us a way to simplify coding the user-defined functions. Further, they let us define anonymous functions. Since, arrow functions provide us a way to write shorter syntax, by including arrow functions in script single statement functions can be created fast and prevent unnecessaey coding. However, there are certain differences …

JavaScript Code Examples

The following section provides several JavaScript Code Examples. addEventListener() Sometimes we want to attach an event listener to an HTML element dynamically. For this purpose, we can use the addEventListener() method. Even, it is possible to attach an event listener to a paragraph or div element. See Example. appendChild() Basically, this method helps us to append a child …

Changing Style of HTML Elements using getElementsByClassName() Method

In this post on Changing Style of HTML Elements using getElementsByClassName() Method, I will explain how to change the style properties of HTML elements with specific class attribute. Changing Style of HTML Elements To begin with, we will use the getElementsByClassName() method in this example. In order to perform a common operation on all the …

Introduction to HTML DOM Methods in JavaScript

In this article on Introduction to HTML DOM Methods in JavaScript, I will explain the HTML DOM methods and their examples. To begin with, in the earlier post on Document Object Model (DOM), its basic concept is explained. Basically, the JavaScript API for HTML DOM comprises several methods that allow us to add, update, and remove …

JavaScript Practice Exercise

Since JavaScript is one of the popular languages for coding, learners should practice it by writing some code. These beginner-level level JavaScript Practice Exercise questions help them learn the language. JavaScript Practice Exercise Use JavaScript to display pop up boxes (alert box, an alert box with line breaks, confirm box, prompt box) Use JavaScript to call a …