Found 10710 Articles for Web Development

How to wrap setTimeout() method in a promise?

Shubham Vora
Updated on 28-Feb-2023 17:20:12

6K+ Views

The setTimeOut() method executes some block of code or functions after a particular number of milliseconds. Sometimes, we require to resolve or reject the promise after a particular delay, and we can use the setTimeout() method with the promises. In JavaScript, a promise is an object that returns the result of the asynchronous operation. Here, we will learn to resolve or reject promises after some delay using the setTimeOut() method. Example 1 (Promises without setTimeOut() method) In the example below, we have used the Promise() constructor to create a new promise. The promise constructor takes a callback ... Read More

How to wait resize end event and then perform an action using JavaScript?

Shubham Vora
Updated on 28-Feb-2023 17:18:50

2K+ Views

Whenever we resize the web page window, it triggers the ‘resize’ event by default. The ‘resize’ event triggers multiple times while resizing the window. Sometimes, we require to execute some JavaScript code only once when resize event completes. In such cases, we must use the setTimeOut() method with the resize event to execute JavaScript code or function once the event completes. Also, we require to use the clearTimeOut() method. Syntax Users can follow the syntax below to wait resize event completes and then perform an action using JavaScript. window.addEventListener('resize', () => { ... Read More

How to view array of a structure in JavaScript?

Shubham Vora
Updated on 28-Feb-2023 17:17:38

342 Views

The easiest way to debug the JavaScript code is using the console.log(), which many developers use. Sometimes, we require to know the array's structure and stored values for the debugging purpose. In this tutorial, we will learn to view the array of structures. Various methods of JavaScript allow us to check the structure of the array. For example, we can know if the array contains an object, nested array, string, number or Boolean values. Use the JSON.stringify() Method The JSON.stringify() method allows us to convert the JSON objects into the string. An array is also an object ... Read More

How to use polyfill in JavaScript?

Shubham Vora
Updated on 01-Mar-2023 10:38:38

2K+ Views

The developers of JavaScript always keep adding new features to the JavaScript language to improve performance and add better functionalities. Sometimes, it happens that new features don’t support by the old browser versions. For example, the exponential operator is introduced in ES7, and the trailing comma in the object is also valid in ES7. Now, while developing the application, we have added used the exponential operator in the application. It will work with the newer versions of the browser, but if someone is using a very old version of the browser, they can get errors like the exponential operator is ... Read More

Hot Reload in ElectronJs

Shubham Vora
Updated on 28-Feb-2023 16:42:28

4K+ Views

Hot reloading is a powerful feature in ElectronJS that lets developers quickly view their code changes in real time without having to restart the application. It makes the development process faster and more efficient by reducing the time and effort required to test changes. Steps to Implement Hot Reload in ElectronJS The hot reloading feature is implemented using a library called “electron-reload”, and it can be easily integrated into an Electron JS application by following a few simple steps. Users can follow the steps below to implement hot reload in Electron Js − Install the electron-reload module The first step ... Read More

How to vertically flip a text canvas using Fabric.js ?

Shubham Vora
Updated on 28-Feb-2023 16:41:29

576 Views

There are two simple ways to flip a text canvas using Fabric.js vertically. You can use scaleY property or flipY property. The scaleY property determines how much the object should be scaled along the vertical axis. While the flipY property is a boolean property that defines the vertical flip state of an object. Fabric.js is a powerful and flexible JavaScript library that makes it easy to work with HTML5 canvas. It provides an object model that allows you to create, manipulate, and render graphics, images, and text on a canvas. Fabric.js abstracts away the complexities of the HTML5 canvas ... Read More

How to create previous and next button and non-working on end position using JavaScript?

Shubham Vora
Updated on 28-Feb-2023 16:39:53

6K+ Views

There are many ways to create previous and next button and non-working on-end positions using JavaScript. We will cover two approaches to achieve this functionality - one using normal if conditions and the other using the "disabled" attribute. The second approach utilizes the "disabled" attribute to make the button not clickable and updates the button style for nonworking end positions. By implementing these techniques, we can easily navigate through a set of elements, making the user experience more seamless and intuitive. Let’s see both methods with examples for creating this kind of button in JavaScript. Using only if conditions ... Read More

How to create own Ajax functionality?

Shubham Vora
Updated on 28-Feb-2023 16:38:20

226 Views

An Ajax (Asynchronous JavaScript and XML) request is an HTTP request made using JavaScript, typically with the XMLHttpRequest object, to exchange data with a server and update a specific part of a web page without requiring full page refresh. There are two ways to create own Ajax functionality. You can use JSONPlaceholder API or your own file. We will discuss these two ways in detail in this tutorial. Using JSONPlaceholder API JSONPlaceholder is a free online REST API that you can use to test and practice your development skills Syntax Users can follow the below syntax for creating an ... Read More

How to show Page Loading div until the page has finished loading?

Shubham Vora
Updated on 28-Feb-2023 16:36:29

10K+ Views

Rather than showing the whole white or black screen while loading the page, it is better to show the loading indicator, which also improves the UX of the application. Nowadays, there are some libraries available to show loading indicators. However, we can use HTML and CSS to create a customized loading indicator div. In this tutorial, we will use HTML, CSS, and JavaScript to show page loading div until the page has finished loading Use the onreadystatechange event to show the loading indicator while loading the page In JavaScript, the onreadystatechange event triggers whenever the state of the web ... Read More

How to serialize a cookie name-value pair into a Set Cookie header string in JavaScript?

Shubham Vora
Updated on 28-Feb-2023 16:34:55

795 Views

The cookie allows us to store users’ data in the web browser for quick response. For example, when a user opens the profile page in any web application, the web page receives the data from the server. The server also sends the cookies containing the data to store in the web browser. When a user goes on the profile page again, it fetches the data from the cookie rather than fetching it from the server to load the webpage quickly. To get data browser looks in the cookie first, and if it doesn’t find data stored in the cookie, it ... Read More

Advertisements