Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 492 Bytes

File metadata and controls

19 lines (13 loc) · 492 Bytes

better Array.prototype.forEach (breaking)

This feature makes breaking change, not included in breaking-free version

Native forEach of array will not iterate the items pushed during iterating. We fix this.

import 'https://better-js.fenz.land/src/array-prototype/forEach-fix.js';

[ 1, 2, ].forEach( ( item, index, array, )=> {
	if( item < 3 )
		array.push( item*2, );
	
	console.log( item, );
}, );

// without BetterJS logs: 1 2
// with BetterJS logs: 1 2 2 4 4