Found 8894 Articles for Front End Technology

How to transform a JavaScript iterator into an array?

Mohit Panchasara
Updated on 16-Feb-2023 18:33:24

1K+ Views

In JavaScript, the iterator is a collection of elements through which we can iterate and access a single element every iteration. The set, map, or object is an iterator in JavaScript, and we can’t access the elements of the iterator using the index like the array. So, we first require to convert the iterator into the array. Here, we will use different methods like an array.from(), etc., to convert an iterator to the array. Use the for-of loop The for-of loop iterates through every element of the iterator lie set and map. Inside the for-of loop, we can ... Read More

How to toggle between one checkbox and a whole group of checkboxes in HTML?

Mohit Panchasara
Updated on 16-Feb-2023 18:28:30

2K+ Views

The toggling means that whenever a user checks a single checkbox, all checkboxes of the group should be unchecked, and when a user checks any checkbox from the group, a single checkbox should be unchecked. We can achieve this functionality with JavaScript. In this tutorial, we will learn to toggle between one checkbox and a whole group of checkboxes in HTML. Syntax Users can follow the syntax below to toggle between one checkbox and a whole group of checkboxes in HTML. checkboxes.forEach((checkbox) => { checkbox.checked = false; }) In the above syntax, checkboxes is ... Read More

How to skip over an element in .map()?

Mohit Panchasara
Updated on 16-Feb-2023 18:26:02

13K+ Views

In JavaScript, we sometimes require to skip array elements while using the map() method. For example, we need to map value from one array to another array after performing some mathematical operations on the element only if the array value is finite. In such cases, users can use the below approaches to skip over array elements while using the map() method. Use the if-else statement In the array.map() method, we can use the if-else statement to skip over the element. If the element fulfills the if-else statement condition, we need to return the element for mapping; Otherwise, we ... Read More

How to sort strings in JavaScript?

Shubham Vora
Updated on 14-Sep-2023 21:35:27

27K+ Views

The sorting string is to arrange strings in the dictionary or alphabetical order. It is usual to sort the array of strings while developing applications using JavaScript. In this tutorial, we will learn to sort strings in JavaScript. For example, string sorting is very useful here if you got some data from the API and want to show that data in the sorted order. Here, we will learn to sort strings using the built-in methods and various naïve approaches. Use the sort() method to sort strings In JavaScript, sort() is the built-in method we can use with the array. Generally, ... Read More

How to create half of the string in uppercase and the other half in lowercase?

Shubham Vora
Updated on 16-Feb-2023 15:47:47

1K+ Views

To convert strings into lowercase and uppercase, we can use the JavaScript string class’s built-in methods like toLowerCase() and toUpperCase(). Furthermore, we can use the string length property or substring() method to split the string in half part. We will learn two approaches in this tutorial to convert half string to uppercase and the other half to lowercase using JavaScript. Use the for-loop, toUpperCase(), and toLowerCase() method We can use the for-loop to get the half-string. After that, we can use the toUpperCase() method to convert the first half of the string the uppercase. After that, we need to use ... Read More

How to clear the canvas using clearRect in HTML?

Shubham Vora
Updated on 16-Feb-2023 15:45:57

389 Views

We will cover the process of creating a canvas element in the HTML document, selecting it in JavaScript code, and using the clearRect method to clear the entire canvas or a specific area of it. This is a useful technique for creating dynamic and interactive graphics in HTML, and we will walk user through the steps needed to implement it in your own projects. In this tutorial, we will be discussing how to clear the canvas using the clearRect method in HTML. Clearing Canvas with clearRect Users can follow the steps below to clear the canvas using clearRect Step 1 ... Read More

How to check which tab is active using Material UI?

Shubham Vora
Updated on 16-Feb-2023 15:50:06

2K+ Views

Material-UI provides a variety of components that help us to build user interfaces with a consistent look and feel. One of the components that Material-UI provides is the Tabs component, which allows us to create tabbed interfaces in our applications. In this tutorial, we will learn how to check which tab is active using Material-UI, a popular React UI library. Use the useState hook to check which tab is active Users can follow the steps below to check which tab is active using Material UI. Step 1 − First, users need to install Material-UI. We can do this by ... Read More

Highlighting Dropdown Options in ReactJS

Shubham Vora
Updated on 16-Feb-2023 15:43:53

746 Views

Highlighting dropdown options is important because it improves the menu's usability by making it easier for users to identify the options they are hovering over. When a user hovers over an option, it becomes highlighted, making it stand out from the other options. This helps the user quickly identify the option they are interested in and select. Additionally, highlighting dropdown options is a simple but effective way to improve the usability and accessibility of the menu. Creating interactive dropdown menus in ReactJS with option highlighting Users can follow the steps below to implement the option highlighting in the ReactJS dropdown. ... Read More

How to use Checkbox inside Select Option using JavaScript?

Shubham Vora
Updated on 16-Feb-2023 15:33:06

7K+ Views

Sometimes, we require to use the checkbox inside the select option. We can allow users to select multiple options by introducing the checkboxes with the select option. However, if we use the multiple attributes with the tag, it allows us to select them by pressing the ‘ctrl + left click’, but it is a bad UX. So, we can introduce the checkbox inside the menu to improve the user experience. Here, we will use JQuery and JavaScript to manage the values of the checked checkboxes in the menu. Create a custom select menu The element of ... Read More

How to use await outside of an async function in JavaScript?

Shubham Vora
Updated on 16-Feb-2023 15:31:59

1K+ Views

In JavaScript, the async-await keyword is used to make the function asynchronous. If we make any function asynchronous, it works like multithreading and executes the code parallelly, which helps us to improve the application performance. Here, we will learn to use the await keyword outside the asynchronous function. Invoke the function immediately We will use the expression in this approach to invoke the function immediately. We can use the await keyword with the promises or any other function inside the function. Syntax Users can follow the syntax below to use the function expression to invoke the function immediately. (async () ... Read More

Advertisements