1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
'use strict'; const myForOf = (ary, callback) => { const iterator = ary[Symbol.iterator](); while (true) { const iteratorResult = iterator.next(); if (iteratorResult.done) { break; } callback(iteratorResult.value); } }; const ary = ["A", "B", "C"]; myForOf(ary, console.log); |
1 2 3 |
A B C |