HTMLCollection for Loop

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

6K+ Views

The HTML collection is an array of HTML elements. We can access every element of the collection using its index. Also, we can iterate through the array of HTML collections and get all HTML elements of the collection one by one. Sometimes, we require to use for loop to iterate through the collection of all HTML elements. For example, we have created a group of checkboxes, and when the user presses the clear button, we require to clear all checkboxes. We can access all checkboxes in the HTML collection, iterate through it, and uncheck every checkbox. In this tutorial, ... Read More

Uncheck a Radio Button Using JavaScript and jQuery

Mohit Panchasara
Updated on 16-Feb-2023 18:37:31

30K+ Views

Sometimes, we require to uncheck a radio button using JavaScript or JQuery. For example, we use the radio button in the form. When the user presses the clear form button, we need to uncheck all radio buttons and allow again users to choose any option from the radio button. In this tutorial, we will learn various methods to uncheck single or multiple radio buttons using JQuery or JavaScript. Use the JavaScript to uncheck the radio button We can access the radio button in JavaScript using id, tag, name or other ways. After that, we can uncheck the radio ... Read More

Trim a String at Beginning or Ending in JavaScript

Mohit Panchasara
Updated on 16-Feb-2023 18:36:50

3K+ Views

While working with the data, removing the unnecessary white spaces from the string is necessary. So, we need to trim a string at the beginning or end. If we keep unnecessary white spaces in the data, it can cause some issues. For example, while storing the password, if we don’t trim the white space, it can mismatch when users try to log in another time to the app. In this tutorial, we will learn to trim a string at beginning or ending in JavaScript. Use the trimRight() method to trim the end of the string The trimRight() method ... Read More

Transform a String into a Function in JavaScript

Mohit Panchasara
Updated on 16-Feb-2023 18:35:49

3K+ Views

We have given a string and need to convert it into a function in JavaScript. Sometimes, we get mathematical or function expressions in the form of the string, and executing that expression, requires converting strings into the function expression. In this tutorial, we will learn different approaches to converting the given string into a functional or mathematical expression. Use the eval() method The eval() method takes the expression as a parameter and evaluates the expression. For example, if we pass the ‘2 + 2’ string as a parameter of the eval() method, it returns 4 as it evaluates the ... Read More

Usage of Static Keyword in GoLang Class

Akhil Sharma
Updated on 16-Feb-2023 18:34:38

2K+ Views

What is Static Keyword in Golang? The term "static" is used to describe variables, functions, and methods that have a fixed or unchanging value or behavior. In Go, the static keyword does not exist. In go we use the term "variables" to describe the memory locations where data is stored and manipulated. Static variables have a property of preserving their value even after they are out of their scope! Hence, static variables preserve their previous value in their previous scope and are not initialized again in the new scope. Algorithm Step 1 − First, we need to import ... Read More

Transform JavaScript Iterator into an Array

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

2K+ 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

Add Two Complex Numbers by Passing Class to a Function in Go

Akhil Sharma
Updated on 16-Feb-2023 18:32:02

201 Views

In this article, we will write a go language program to add two complex numbers by passing a class to a function. Here we will create a function to the class that will accept the class as an argument along with its properties and we can easily calculate the sum of the provided complex numbers using it. Algorithm Step 1 − First, we need to import the fmt package. Step 2 − Then, create the structure named Complex and define in it the properties real and imaginary. Step 3 − Then create a function to the complex class declared ... Read More

Print Boundary Elements of a Matrix in Golang

Akhil Sharma
Updated on 16-Feb-2023 18:31:35

201 Views

What is Boundary Elements? In go programming language. the boundary elements of a matrix are the elements that are located on the outer edge of the matrix. They are located at four positions i.e the first row, the last row, the first column and at the last column. In a matrix of size m x n, the top boundary elements are the elements in the range matrix[0][0] to matrix[0][n-1], the bottom boundary elements are the elements in the range matrix[m-1][0] to matrix[m-1][n-1], the left boundary elements are the elements in the range matrix[0][0] to matrix[m-1][0], and the right boundary elements ... Read More

Toggle Between One Checkbox and a 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

Skip Over an Element in Map

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

16K+ 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

Advertisements