-
JavaScript Array valueOf() method
The valueOf() method in JavaScript is used to return the primitive value of an array. This method returns the original array, not a copy or reference to the array. Here is an example of how the valueOf() method works: In the code example above, we first declare an array called array1 that contains the numbers […]
-
JavaScript Array some() method
The some() method in JavaScript is used to determine whether at least one element in an array satisfies a specified condition. This method returns a Boolean value indicating whether at least one element in the array passes the test implemented by the provided callback function. Here is an example of how the some() method works: […]
-
JavaScript Array reduceRight() method
The reduceRight() method in JavaScript is used to apply a function to each element in an array, in order to reduce the array to a single value. This method is called on an array, and takes a callback function as an argument. The callback function is called for each element in the array, and is […]
-
JavaScript Array lastIndexOf() method
The lastIndexOf() method in JavaScript is used to search an array for a specified element, and returns the index of the last occurrence of the element in the array. If the element is not found in the array, the lastIndexOf() method returns -1. Here is an example of how the lastIndexOf() method works: In the […]
-
JavaScript Array keys() method
The keys() method in JavaScript is used to return a new Array Iterator object that contains the keys for each index in the array. This method is typically used in conjunction with the for…of loop to iterate over the elements of an array. Here is an example of how the keys() method works: In the […]
-
JavaScript Array.isArray() method
The Array.isArray() method in JavaScript is used to determine whether a value is an array. This method returns a Boolean value indicating whether the value is an array or not. Here is an example of how the Array.isArray() method works: In the code example above, we first declare an array called array1 that contains the […]
-
JavaScript Array indexOf() method
The indexOf() method in JavaScript is used to search an array for a specified element, and returns the index of the first occurrence of the element in the array. If the element is not found in the array, the indexOf() method returns -1. Here is an example of how the indexOf() method works: In the […]
-
JavaScript Array includes() method
The includes() method in JavaScript is used to check if an array includes a specified element. This method returns a Boolean value indicating whether the specified element is found in the array. Here is an example of how the includes() method works: In the code example above, we first declare an array called array1 that […]
-
JavaScript Array.from() method
The Array.from() method in JavaScript is used to create a new array instance from an array-like or iterable object. This method is typically used to convert a non-array object (such as a NodeList or Set) into an array, so that array methods can be used on it. Here is an example of how the Array.from() […]
-
JavaScript Array findIndex()
The findIndex() method in JavaScript is used to find the index of the first element in an array that satisfies a specified condition. This method returns the index of the first element in the array that passes the test, or -1 if no such element is found. Here is an example of how the findIndex() […]