« March 2004 | Main | June 2004 »
April 21, 2004
Nifty little Array Trick
Not the most amazing discovery in the world but I came across a nifty little array trick earlier today.
For the past few weeks I have been in debug mode so I've been digging through a bunch of arrays. Every now and then the most minuet and insignificant detail will bother me. In this particular case it was the commas in the array:
var a = new Array(1,2,3,4);
trace(a);
// Output
1,2,3,4
For small sets of data no biggie. However, I'm dealing with thousands of lines of data. Hence my solution:
trace(a.join(newline));
// Output
1
2
3
4
Woohoo! I know it's not that big of a deal and it's not going to save you anytime or speed anything up. But it sure is purty and didn't require a customer formater class.
Posted by erikbianchi at 07:27 PM | Comments (254)