Reiterate 1.2: operators are (kind of) methods now!
You know how, in Ruby, + is a method? Well guess what:
// Count members within a range
numbers.findAll({'>': 4, '<=': 27}).length
// Remove items of a specific type
collection.reject(['instanceof', String])
// Assign default values to a collection
[27, 0, 'prototype', '', true, false].map({'||': 'foo'})
// -> [27, "foo", "prototype", "foo", true, "foo"]
How’s about that then?
About this entry
You’re currently reading “Reiterate 1.2: operators are (kind of) methods now!,” an entry on The If Works
- Published:
- 9.27.07 / 6pm
- Category:
- JavaScript, Prototype, Reiterate
- Tags:
No comments
Jump to comment form | comments rss [?] | trackback uri [?]