Found 8894 Articles for Front End Technology

JavaScript: How to check whether an array includes a particular value or not?

Mayank Agarwal
Updated on 22-Apr-2022 13:31:28

168 Views

In this article, we will be discussing the construction of an array. Once the array is created we will be looking out for a value by checking whether it exists in the array or not.But before checking for any particular value, let’s see how the arrays are created in JavaScript.Syntaxlet array = [arrayItem1, arrayItem2, arrayItem3 ...]Once the array is created, let’s see how to search for a specific value from the array. There are multiple approaches to searching for whether an element exists in the array or not. Below we are going to discuss the same.Approach #1This is a traditional ... Read More

JavaScript: How to check if a number is NaN or finite?

Mayank Agarwal
Updated on 22-Apr-2022 13:24:59

413 Views

Often we need to check whether a finite number or undefined returns the same to the user. In this article also we will be checking if a number is actually a finite number or Not a Number, i.e., NaN.Below is the method to check whether a number is finite or not.isNaN()This is a method provided by JavaScript to check whether a number is a finite number or not. If this method returns false, then the number is a finite number else the number is not finite.SyntaxisNaN(number )Example 1In the below example, we are going to use the above method to ... Read More

JavaScript: How to check if a number is even without using the modulo operator?

Mayank Agarwal
Updated on 22-Apr-2022 13:20:34

716 Views

Often we need to check whether a number is odd or even and return the same to the user. In this article also we will be checking whether a number is even or not but without using the modulo operator. It’s pretty easy to check whether a number is even by using the modulo operator. But we can also check a number with other possible methods.Below we are going to see the other methods for checking a number and its properties.Approach #1: Using the for() loopIn this method, we are going to use the for() loop to check whether a ... Read More

How to chain asynchronous functions in JavaScript?

Mayank Agarwal
Updated on 22-Apr-2022 12:54:13

1K+ Views

JavaScriptis a single-threaded synchronous function that performs operations. It is a timeconsuming operation that blocks other operations of the thread.We can use the asynchronous programming provided by JavaScript that performs functions without blocking other operations of the thread. This can be done by asynchronous code like promises or async functions (which basically are cleaner promises).Asynchronous functions are cool but the time of their execution is not certain which might create a problem. Also, it is not easier to track async functions for any potential errors.In this article, we will be exploring the chaining of asynchronous functions using ES2015+ features like ... Read More

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

Mayank Agarwal
Updated on 22-Apr-2022 12:46:27

2K+ Views

In this article, we are going to explore constructors in an object. We can create inheritance in terms of object, i.e. a parent object can have one or multiple child objects. Now we can call the constructors of a parent object from the child object.ConstructorThese are the instances of a class that is commonly referred to as an Object. The new keyword from JavaScript uses a constructor to be called when an object needs to be declared or created. We can set properties into an object using these constructors.Inheritance in JavaScriptThis is the ability of an object to access the ... Read More

How to call a JavaScript function in HTML?

Mayank Agarwal
Updated on 22-Apr-2022 12:40:47

2K+ Views

In this article, we will be exploring the calling and initialization of the JavaScript function from an HTML template. We require the JavaScript function to execute the desired methods over the input passed.In this tutorial, we will be discussing two major approaches to calling a JavaScript function from an HTML page.In the first Approach, we are going to take a simple input tag and a Submit button associated with it. Once the button is clicked we will see a dialog box that pops up on the screen as an alert. This button on click calls invokes the JavaScript function to ... Read More

How to add HTML elements dynamically using JavaScript?

Mayank Agarwal
Updated on 22-Apr-2022 12:31:57

3K+ Views

In this article, we will be exploring how to add HTML elements dynamically so that they could change the view component. Also not just an HTML element, we can also add CSS properties to HTML elements with the help of JavaScript. In this article, we will be using a button to facilitate the addition of an HTML element in the already built template.ApproachWe will create a Simple HTML page with some components defined.Once the page is created we will be writing some outer HTML and adding a button to it so that we could add this HTML when a user ... Read More

How to Add Google Maps to a Website?

Mayank Agarwal
Updated on 22-Apr-2022 12:25:45

805 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.StepsBelow 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 container to place Google Maps.Adding the external script provided by Google inside the HTML document.Write the JavaScript ... Read More

How does JavaScript work behind the scene?

Mayank Agarwal
Updated on 22-Apr-2022 12:19:48

438 Views

JavaScript is a relatively new language with lots of new features and enhancements over the traditional HTML & CSS pipelines. With the new age era, JavaScript has captured most of the frontend market in a relatively lower period of time. It has gained tremendous popularity and is the go to language for any frontend needs.In this article, we are going to explore how does the traditional JavaScript works behind the frontend templates. How it processes the elements and how it executes them?JavaScript is a synchronous, single threaded language with specific order of execution.Everything inside a JavaScript function executes inside the ... Read More

How does asynchronous code work in JavaScript?

Mayank Agarwal
Updated on 22-Apr-2022 12:15:14

233 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 codeSynchronous Code − This implies that the user is having the data that is synchronously called and accessed as available in the order. In this user calls the method and only after the method is called it is executed and checked.In Asynchronous code, the trigger is hit by a user or system. It is not necessary who ... Read More

Advertisements