With my project 'Metho' - we can easily safely add 'dynamic properties' to the Array prototype that could do what you are suggesting. We could make something like the following:
const arr = [2, 1, 3] console.log( arr[reversed] ) // [3, 1, 2] console.log( arr[sorted()] ) // [1, 2, 3] const descending = (a, b)=>b-a console.log( arr[sorted(descending)] ) // [3, 2, 1] console.log( arr ) // [2, 1, 3] - no mutation occurred // etc...
I'm actually planning a metho-array library, so I'd probably include all/most of the above in that
metho-array
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
With my project 'Metho' - we can easily safely add 'dynamic properties' to the Array prototype that could do what you are suggesting. We could make something like the following:
I'm actually planning a
metho-array
library, so I'd probably include all/most of the above in that