Skip to content
Related Articles

Related Articles

JavaScript | typedArray.@@iterator with Example
  • Last Updated : 03 Aug, 2018

The typedArray.@@iterator is an inbuilt property in JavaScript which is used to return the initial value of the given typedArray’s element.
Syntax:

arr[Symbol.iterator]()

Parameters: It does not accept any parameter because it is a property not a function.
Return value: It returns the array iterator function i.e, values() function by default.
JavaScript code to show the working of this property:




<script>
  
    // Constructing a new typedArray with some elements
    var A = new Uint8Array([ 5, 10, 15, 20, 25 ]);
  
   // Calling iterator() function
    var a = A[Symbol.iterator]();
  
    // Printing each value of the typedArray
    document.write(a.next().value + "<br>");
    document.write(a.next().value + "<br>");
    document.write(a.next().value + "<br>");
    document.write(a.next().value + "<br>");
    document.write(a.next().value);
  
</script>


Output:

5
10
15
20
25

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :