Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A custom property on an array is **not iterable**
- const arr = [1,2];
- arr[10] = 10; // => [1, 2, undefined*8, 10]
- arr['ok'] = 'ok';
- // for-in: enumerable properties:
- for (const index in arr) console.log(arr[index]); // => 1, 2, 10, 'ok'
- // for-of: iterable
- for (const value of arr) console.log(value); // => 1, 2, undefined*8, 10
- // forEach: strip undefined???
- arr.forEach(value => console.log(value)); // => 1, 2, 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement