2011 Dec 3, 6:46
Cool and (relatively) new methods on the JavaScript Array object are here in the most recent versions of your
favorite browser! More about them on ECMAScript5, MSDN, the IE blog, or Mozilla's documentation. Here's the list that's got me excited:
-
some & every
-
Does your callback function return true for any (some) or all (every) of the array's elements?
-
filter
-
Filters out elements for which your callback function returns false (in a new copy of the Array).
-
map
-
Each element is replaced with the result of it run through your callback function (in a new copy of the Array).
-
reduce & reduceRight
-
Your callback is called on each element in the array in sequence (from start to finish in reduce and from finish to start in reduceRight) with the result of the previous callback call passed to
the next. Reduce your array to a single value aggregated in any manner you like via your callback function.
-
forEach
-
Simply calls your callback passing in each element of your array in turn. I have vague performance concerns as compared to using a normal for loop.
-
indexOf & lastIndexOf
-
Finds the first or last (respectively) element in the array that matches the provided value via strict equality operator and returns the index of that element or -1 if there is no such element.
Surprisingly, no custom comparison callback method mechanism is provided.
-
javascript array technical programming 2011 Nov 28, 7:36
Last time I wrote about how I switched from Delicious
to Google Reader's shared links feature only to find out that week that Google was removing the
Google Reader shared links feature in favor of Google Plus social features (I'll save my Google Plus rant for another day).
Forced to find something new again, I'm now very pleased with Tumblr. Google Reader has Tumblr in its preset list of Send To sites which makes it
relatively easy to add articles. And Tumblr's UX for adding things lets me easily pick a photo or video to display from the article - something which I had put together with a less convenient UX
on my bespoke blogging system. For adding things outside of Google Reader I made a Tumblr accelerator to hookup to the Tumblr Add UX.
Of course they have an RSS feed which I hooked up to my blog. The only issue I had there is that when you add a link (and not a video or photo) to Tumblr, the RSS feed entry title for that link
is repeated in the entry description as a link followed by a colon and then the actual description entered into Tumblr. I want my title separate so I can apply my own markup so I did a bit of
parsing of the description to remove the repeated title from the description.
blog tumblr me technical google-reader 2011 Nov 25, 4:52
2011 Sep 10, 10:36video 2011 Jul 9, 1:49Glasses that whisper in your ear the mood of the person with whom you're speaking and a jerk-o-meter you wear around your neck that tells you when you're being a jerk. Social devices.
social science tool augmented-reality