The Javascript TypedArray entries() method is used to get a new Array Iterator object that contains key-value pairs for each index in the array. Array index is represented by key and array item is represented by value.
Syntax:
array.entries()
Returns:
Array Iterator object.
Example:
<!DOCTYPE html> <html> <body> <script type="text/javascript"> var Jewels = ["DIAMOND","GOLD","PLATINUM","SILVER"]; var gems = Jewels.entries(); document.write(gems.next().value + "<br>"); document.write(gems.next().value + "<br>"); document.write(gems.next().value + "<br>"); document.write(gems.next().value); </script> </body> </html> |
Output:
0,DIAMOND 1,GOLD 2,PLATINUM 3,SILVER |
Please Share