Crow-Eating Time

There is an erroneous statement on p.599 of Ajax in Action. I’m discussing weird things that one can do with the JavaScript prototype, and incorrectly state that altering the prototype of an object after it is created won’t affect the properties of the already-created object. In fact, it will.

In any event, it’s a well-contained bug, as this sort of thing is very much an edge-case use of JavaScript. In that section of the book, and elsewhere, I advise against doing this sort of on-the-fly recomposition of object types, and don’t do it myself. If you do feel the urge to do this sort of thing, then I have two bits of advice for you:

  • think about why you feel the need to do it, and find a cleaner way of achieving your aims
  • if you really do need to do it, don’t listen to p.599 of Ajax in Action!

Kudos to Brian Andrew Smith, who was observant enough and kind enough to point out the mistake to me in the Manning forums.

Comments are closed.