I18n - defining format() and compare() as getters to simplify usage

Nebojša Ćirić cira at google.com
Tue Jan 31 10:04:12 PST 2012

We (i18n group) mentioned slight problem with Collator.compare() method to
Allen at the last i18n meeting.

The problem is that you can't do:

var col = new Intl.Collator(...);

because of the binding loss.

Allen proposed something like this as a possible solution (typing from

Collator.prototype = {
  get compare(a, b) {
     var that = this;
     return function(a, b) { uses that; return a < b };

It seems that all major JS libraries*, except jQuery, try to help user not
to stumble on this problem. Should we include this into spec?

I think that if we do it for compare() method, we should then do it for
format() methods too, since that would allow user to pass functions around
instead of objects.

This should not apply to supportedLocalesOf functions.

What do you think?

* http://www.alistapart.com/articles/getoutbindingsituations/ (see
"JavaScript frameworks do it" section)

Nebojša Ćirić
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120131/23182dd3/attachment.html>

More information about the es-discuss mailing list