Nikhilesh Aleti

Nikhilesh Aleti

69 Articles Published

Articles by Nikhilesh Aleti

Page 7 of 7

Return an array of all the indices of minimum elements in the array in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 22-Sep-2022 1K+ Views

An Array in JavaScript is a single variable where it can store different elements. These elements are stored at contiguous memory locations. Array elements can be accessed with the help of index numbers. The index numbers will start from 0. Syntax Below is the basic declaration of the array in JavaScript − Cosnt cars = [Maruti, Hyundai, Honda]; We need to return an array of all the indices of minimum elements in a JavaScript array Let’s look into the input-output scenario Assume there is an integer array where the minimum element is repeated more than once. We need to ...

Read More

How to remove the 0th indexed element in an array and return the rest of the elements in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 19-Sep-2022 935 Views

Array is a structure, which can hold values elements and they can be accessed by referencing to them with the help of index numbers. Const colors = [“Green”, “Maroon”, “Blue”]; Reference index of array In JavaScript arrays are referred with reference indexes. These indexes are zero-indexed. The very first element in the array will be 0 index. Second element will be index 1. Last element in the array will be the total size of the array minus 1. Spread operator (…) In this article, we are going to discuss how to remove the 0th indexed element in an ...

Read More

Is 'floating-point arithmetic' 100% accurate in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 19-Sep-2022 603 Views

Floating point A number which is either positive or negative whole number with having a decimal point to it is called floating point. Let’s consider these numbers, 1.52, 0.14 and also -98.345 are considered as floating point numbers. Whereas 77, 56, 90 and 0 are not considered as floating point numbers. In JavaScript this format will store the numbers in 64 bits. The numbers which are in fraction are stored in 0 to 51 bits. Coming to exponent, they are stored in 52 to 62 bits. And the sign bits will be stored in 63rd bit. Floating point arithmetic Floating ...

Read More

How to convert a string to a floating point number in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 19-Sep-2022 2K+ Views

In this article, we are going to discuss how to convert a string to a floating-point number in JavaScript. We can convert a string to a floating point in three ways − Using the parseFloat() method. Using the parseInt() method. Using type conversion. Using the parseFloat() method The parseFloat() is a function in JavaScript, this accept the string as input and convert the value into a floating point number. Let’s consider a scenario where there is numeral value in the string and also if the first character of the string is not a number then the resultant output ...

Read More

How to find the common elements between two or more arrays in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 19-Sep-2022 10K+ Views

Arrays is typeof operator in JavaScript. Arrays can access its elements with the help of index numbers which starts with 0. Let array = [“India”, “Australia”, “USA”]; There are enough number of ways to get the common elements from the arrays. Now, In this below scenario we use for loop for finding common arrays. In this article, we are going to discuss how to find the common elements between two or more arrays in JavaScript. Using for loop One way to find the common elements between two or more arrays is using the simple for loop. Following are the ...

Read More

How to select a radio button by default in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 19-Sep-2022 14K+ Views

Radio button A radio button is used to select one among many options. This is one of the element in HTML. This radio button is a radio group to show a set of multiple choices, and in that only one can be selected. This way far similar to checkboxes, in checkboxes scenario’s we can select either one or many options as we can, whereas in radio button it can’t be done selecting multiple choices. We can define radio button is HTML using tag. Following is the syntax to define radio buttons in HTML Example 1 None selected ...

Read More

How to use spread operator to join two or more arrays in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 16-Sep-2022 8K+ Views

Array is a variable. Which has an ability to store multiple values in it using appropriate syntax. Every value is referred with index numbers which will start from 0. Const ipl = [“Chennai”, “Mumbai”, Hyderabad”]; Spread operator (…) Spread operator can do the copying of one object or array’s properties and values to another object or array. This will be a shallow copy of the original. Const ipl = [“Chennai”, “Mumbai”, Hyderabad”]; Spread operator can do the copying of one object or array’s properties and values to another object or array. This will be a shallow copy of ...

Read More

How to find maximum value in an array using spread operator in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 16-Sep-2022 1K+ Views

In this article, we are going to discuss how to find the maximum value in an array using the spread operator in JavaScript. For this you need to understand what is an array, what is spread operator and Math.max() method. Array An Array is a variable which is used to store different types of elements. Used to store a bunch of elements and access them with a single variable. Declaration of array can be done in below methods. var House = [ ]; // method 1 var House = new Array(); // method 2 Spread operator (…) This ...

Read More

How to clone an array using spread operator in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 16-Sep-2022 3K+ Views

In this article, we are going to discuss how to use the spread operator to clone an array in JavaScript. Cloning is just the process of copying one array into another array. Previously, the slice() method was used to clone an array, however, ES6 now provides the spread operator(...) to simply clone an array. Before proceeding further let us look at the definitions of array and spread operator. Array An Array is usually a data structure, in JavaScript it is an object which can hold multiple values at once. For example, Below “Arr” is an array. Const Arr = [‘Tutorials’, ...

Read More
Showing 61–69 of 69 articles
« Prev 1 3 4 5 6 7 Next »
Advertisements