Found 8895 Articles for Front End Technology

How to write a simple code of Memoization function in JavaScript?

Shubham Vora
Updated on 01-Mar-2023 10:46:23

271 Views

Memoization is the optimization technique to improve the performance of the function. Before we start with the memoization technique, let’s understand why we require it using the example below. Example (Naïve approach to finding Fibonacci number) In the example below, we have implemented the naïve approach to find the nth Fibonacci number. We used the recursive approach to find the nth Fibonacci series. Finding the nth Fibonacci using recursive approach number in JavaScript Enter the number to find the nth Fibonacci number. ... Read More

How to write a cell phone number in an international way using JavaScript?

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

501 Views

When you have visitors from worldwide on your websites, it is a good idea to show things like a cell phone number according to international standards. So they can easily understand. We can use the International Public Telecommunication Numbering Format to represent the cell phone number in an international way. Also, it is represented by the ‘E-164’ format. We have given the syntax below to follow to write a cell phone number in an international way. [+] [country code] [local phone number] Users can see that the international phone number contains ‘+’ initially and ‘country ... Read More

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

How to create refs in ReactJS?

Shubham Vora
Updated on 28-Feb-2023 17:14:40

344 Views

In ReactJS, refs are used to referring any node of the document. Generally, we can pass the props to children elements to interact with children from the parent’s state. Still, sometimes the child component is out of the typical dataflow of components. For example, we have four components, and dataflow is second is a child of the first, third is a child of the second, and fourth is a child of the third component. To interact with the fourth component from the first component, passing props from every component is not good practice. So, we can use refs to interact ... Read More

How to create progress bar in ReactJS?

Shubham Vora
Updated on 28-Feb-2023 17:13:27

9K+ Views

We can use the progress bar to track how many percentage of a particular task is completed. Maybe you have seen the progress bar on many websites while uploading a file, and it is one of the best use cases of the progress bar to show the uploaded percentage of uploading the file. Another best use case of the progress bar is showing the download completion percentage. We can use different CSS styles for the progress bar to animate and improve user experience. In this tutorial, we will learn to create a progress bar using libraries and from scratch ... Read More

How to Create Phone numbers and Contacts List in ReactJS?

Shubham Vora
Updated on 28-Feb-2023 17:11:44

705 Views

We can assume that you have used mobile devices to call someone and seen the contact list. Generally, when you open the phone book on most mobile devices, it will show you three sections. The first is a keypad to dial a custom number, the second is recent calls, and the third is saved contacts in the device. The recent contact section shows recent calls with names, numbers, and call duration. The normal contact list section shows your contact name with your contact number. Here, we will design a contact list in ReactJS using the basic functionalities of ReactJS. ... Read More

How to create an Image Slider in ReactJS?

Shubham Vora
Updated on 28-Feb-2023 17:10:58

17K+ Views

Image slider is crucial in any web application to show multiple images with good UX. Whenever we go on any prestigious site like amazon.com or cardekho.com, they show images in the slider, and these websites need to show multiple images for every product. Now, what if they show every single image without a slider, users can’t see the image properly, and it looks worst. So, in this tutorial, we will learn various approaches to creating an image slider in ReactJS. Use the react-simple-image-slider Npm package The react-simple-image-slider allows us to create an image slider in ReactJS. Users ... Read More

Advertisements