for(var index = 0, length = listItems.length; index < length; index++) { listItems[index].remove(); }
and I think to myself -
_(listItems).invoke('remove')
for(var index = 0, length = listItems.length; index < length; index++) { listItems[index].remove(); }
and I think to myself -
_(listItems).invoke('remove')
In the novel native martians do exist and they are very smart. "Grok" it's the martian word for "water" and "to drink". Water is a scarce resource there, and, like here, very important for life.
Drinking is putting water inside you but also occurs that this water becomes part of you.
Then, in that society, drinking is used as the metaphor for understand something in a level that becomes part of you.
I'm a native spanish speaker and I don't know if that word sounds bad in english, but for me the metaphor is so powerful and beautiful that I like it very much.
"To really understand something REALLY well".
[1] http://wikibin.org/articles/baader-meinhof-phenomenon.html
As a Lisp hacker and current learner of Haskell, this makes my spleen rupture.
It's just functional programming 101, seriously.
That's all it is.
map (.remove!),list-itemsIn simple terms, it goes through the array, and calls the named function on every element. You could read it as - "For this array, invoke the 'remove' function on every element."
My point basically was that
_(listItems).invoke('remove')
is actually short for
* [content of http://underscorejs.org/underscore-min.js] _(listItems).invoke('remove')*
and even if you removed all non-called parts from underscore, that's still a lot more complex than
for(var index = 0, length = listItems.length; index < length; index++) { listItems[index].remove(); }
it's just hidden, out of sight and out of mind.
They were attempting to use a meme acronym sarcastically -- an example of content-free commenting that works well for karma elsewhere but hopefully doesn't gain a foothold here.
On topic, I agree with your amplification of your point.
(They tend to be downvoted to oblivion, 'round these parts.)
I guess while syntactic sugar is usually considered a functionality of the language itself, it surely is used in the way I meant it, too... random search result:
http://www.developerdrive.com/2012/05/an-introduction-to-und...
"In this part of the tutorial we’re going to take a look at some of the syntactic sugar that Underscore gives us to work with array-like collection."
And of course, even if I had been utterly wrong for using the term, my point would stand unmoved, but you know that :)
Underscore as a production library is 4kb. The functions are terse, and its extremely easy to understand what they're doing - nothing is generally hidden (this example is pretty easy to understand, yet one of the most "complex" uses of underscore I've seen).
At the end of the day on a production javascript app of multiple thousand lines of JS, it likely actually saves me bytes over the wire from not having to write "for(var x = 0...." every time I want to iterate through something or filter an array or find if an array includes something etc (There's around 70 bytes removed in this single example).
But if you do it a lot in your code, that just means you can easily copy and paste it from a nearby place? At least that's what I often end up doing.
http://jsperf.com/native-for-loop-vs-array-foreach-and-array...