Is there are shorter way than using each() to apply something to each item within an array?
Hi Guys,
So I've done some development using the groovy language recently and wondered if javascript or jquery has something similar (I'll just use pseudo code to illustrate my point faster).
Say I have a function that accepts an array of strings, but the array I have contains integers:
myFunction([1, 2, 3, 4])
Lets say there was a function called toString in the library that converted objects to strings. If I tried just doing [1, 2, 3, 4].toString() it would just convert the array object into a string ('[1, 2, 3, 4]')
What I want is for the toString to act on the items inside the array and not on the array itself. In groovy I can access the individual items with an astrix:
[1, 2, 3, 4]*.toString()
This is like doing an each and calling toString() on each item, but does it in one line.
Just wondering if a shorthand like this exists in javascript/jquery?
Thanks,
guyver_dio