Object.prototype.* writable?

Allen Wirfs-Brock allen at wirfs-brock.com
Sun May 8 14:28:34 PDT 2011


I'm generally on board that modules are the real solution to ensuring reliable access to built-ins.  It has occurred to me that a reliable, ES5 level, way to access built-ins might be a useful feature for implementations to do something like the following:

For example, there might be a "frozen" global named something like "ES5Builtins" whose values was a preinitialized object structures of the form:

Object.freeze( {
  Object: Object.freeze({
      getProtypeOf: Object.getPrototypeOf,
      getOwnPropertyDescriptor: Object.getOwnPropertyDescriptor,
      create: Object.create,
      ...
      keys: Object.keys,
     Object_prototype: Object.prototype,
      prototype: Object.freeze({
          constructor: Object,
          toString:  {}.toString,
          toLocaleString: {}.toLocaleString,
          valueOf: {}.valueOf,
          isProtototypeOf: {}.isPrototypeOf,
          propertyIsEnumerable: {}.propertyIsEnumerable
      }),
  }),
 Function: Object.freeze({
   Function_prototype: Function.prototype,
   prototype: Object.freeze({
          constructor: Function,
           toString: Function.prototype.toString,
           apply: Function.prototype.apply,
           call: Function.prototype.call,
           bind: Function.prototype.bind
      }),
  }),
Array: Object.freeze({
   isArray: Array.isArray,
   Array_prototype: Array.prototype,
   prototype: Object.freeze({
          constructor: Array,
          toString:  [].toString,
          ...
      }),
  }),
...
})


More information about the es-discuss mailing list