15.2.4.3 Object.prototype.toLocaleString()

2010-07-04

string Object.prototype.toLocaleString() throws TypeError

This is an interface method to allow certain objects to have their own locale sensitive version of the method. Date, Array and Number use this. Unless overridden this function will call and return this.toString().

The this value will be coerced to an Object.

Code: (Meta Ecma)
Object.prototype.toLocaleString = function(){
var O = toObject(this);
var toString = O.[[Get]]('toString'); // get the method
if (!IsCallable(toString)) throw TypeError;
return toString.[[Call]](O);
}

The specification notes that the first parameter of this function is likely to be used in a future release of the specification and is best not to be used in a custom implementation.