DEV Community


Discussion on: 10 Syntax differences between Haxe and Javascript

markknol profile image
Mark Knol • Edited

Nice comparison! As for the mapi method, In Haxe you can also use a shorthand notation for this: (using array comprehension and the key-value iterator)

// Haxe

class MyThirdAwesomeClass {
  function testArrayMap():Array<Int> {
    var myArray:Array<Int> = [0, 1, 2];

    return [for (index => number in myArray) Number + Index];
Enter fullscreen mode Exit fullscreen mode