In this article, I will explain Creating User-Defined Functions in javaScript. Since many times we need to use the same program statements at several places in a program. Therefore, we create functions that perform a specific task. These functions are called user-defined functions. Once, we have a function for performing a specific task, we can …
Popup Boxes in JavaScript
The following example demonstrates how the Popup Boxes in JavaScript work. Basically, JavaScript offers three popup boxes. In order to display a warning message, we use the alert popup box. It displays a warning message along with an OK button. In order to proceed further, the user requires to press the OK button. Similarly, we …
Creating Classes in JavaScript
In this article on Creating Classes in JavaScript, I will explain how to create and use classes in JavaScript. In fact, ES6 introduces classes in JavaScript. Basically, a class encapsulates data and associated methods. The following code shows the syntax of a class in javaScript. Syntax of a JavaScript Class Examples of Creating Classes in …
Understanding HTTP Requests and Responses
This article explains HTTP Requests and Responses. In order to get data from another server HTTP Requests are made. Basically, these requests occur between API endpoints. API End Points Generally, two servers interact with each other using web services. So, one of the servers is making a request for a resource. While the other one …
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 …
JavaScript Code for Event Handling
The following section demonstrates a JavaScript Code for Event Handling. Before discussing the code, let us understand, how the event handling is done in JavaScript. Event Handling in JavaScript As a result of the user’s actions, a variety of events may occur on a web page. While, it is necessary that some action should be done in …
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 …
Show or Hide TextBox when Selection Changed in JavaScript
In this post on Show or Hide TextBox when Selection Changed in JavaScript, I will demonstrate how to display a textbox or hide it when a specific option is selected in a drop-down list. Although we use a dropdown list in order to provide the user a number of options in which he or she can select …