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?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>