• That was quick - Thanks , I prefer the one-liner ;-)

    Keep in mind that this allocates a new array every time

    Else you modify array p[] , or am I missing something here?

  • Yes, foreach, for loop modifies the array in place (ok, you can create a new array, but usually you don't). Just console.log out after each call to compare the different ways.

About

Avatar for MaBe @MaBe started