Loading ...
Sorry, an error occurred while loading the content.

[jslint] Re: Arguments class

Expand Messages
  • Douglas Crockford
    ... I was anticipating that Object.beget was going to be added to the language, and it was, but the committee changed the name to Object.create, which I
    Message 1 of 7 , Feb 22, 2010
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Randy Cox <rcox@...> wrote:
      >
      > > I recommend that you not hang stuff on Array or any of the other global
      > objects. The Prototype library
      > > does that, creating interoperability problems.
      >
      > Douglas,
      >
      > How can this recommendation coexist with all of the examples of augmented
      > objects that you list in the Good Parts book? Object.beget,
      > Function.method, Function.inherits, Number.integer, String.trim,
      > Array.reduce, etc. Where do you draw the line between acceptable and
      > unacceptable augmentation?


      I was anticipating that Object.beget was going to be added to the language, and it was, but the committee changed the name to Object.create, which I corrected in the second printing. Similarly, String.trim is now in the language.

      Adding things to prototypes can be beneficial but is risky. We have been doing this long enough now that we know the risks.

      Adding things directly to system objects like Array is not beneficial, and can interfere with future developments. ES5 adds new methods to Object because it was likely that some breakage would occur if they were added to Object.prototype, increasing the sorts of hazards that we see with hasOwnProperty.
    Your message has been successfully submitted and would be delivered to recipients shortly.