COMMUNITY

JS NodeList forEach

Hej !

Is there a reason why forEach isn’t implemented in NodeList please ?
I know it’s easy to iterate inside using basic haxe iterator but it’s just handy to have the “index” number in forEach function.

Haxe will add key value iterators eventually. Edit: they are available now in haxe 4.0.0

In the meantime you can probably work around this using static extensions: https://try.haxe.org/#34469

Thanks Mario for your answer.

Yes this actually works in haxe :

var a = [ "a", "b", "c"];
for( k=>v in a ){
    trace( k, v ); // 0, "a" - 1, "b", - 2, "c"
}

But I just wanted to know if it’s a forgetting if .forEach does’nt exist or it will never be implemented ?

@basro “Eventually”? :slight_smile:

image

I can’t take one step without embarasing myself :stuck_out_tongue: