for vs map

Edit on GitHub

map vs for

Setup

a = "fguzsdfkghsdf".split``

Tests

  • for

    for (var i = a.length - 1; i >= 0; i--) {
        a[i] = 5;
    };
  • map

    a.map(u=>u=5)