tc39 / Function-prototype-toString-revision

:fishing_pole_and_fish: ECMA-262 proposal to update Function.prototype.toString
https://tc39.github.io/Function-prototype-toString-revision
26 stars 10 forks source link

Impose requirements on BindingIdentifier #9

Closed gibson042 closed 8 years ago

gibson042 commented 8 years ago

This proposal guarantees that Function.prototype.toString will represent callable built-in objects as NativeFunction productions, but imposes no requirements around presence or value of the resulting identifier. It would be very convenient for utilities like lodash isPlainObject if, when the method is called against objects appearing in the "Well-known Intrinsic Objects" table, the identifier could be specified to a) exist, and b) have a predictable value derived from the table (e.g., so Function.prototype.toString.call(Object) matches /function Object\b/). Similar treatment of built-in functions not appearing in the table (e.g., Array.prototype.push) would be nice but not required. Note, however, that modern implementations already do both.

A uniqueness constraint (per-realm or otherwise) could also be valuable, especially for dealing with bound functions, but is strictly less important than the above.