Skip to content

Comment on Javascript: Stop Fighting It

Comments

"First, let's write the following: Object.prototype.clone"

Never, ever add things to Object.prototype. It breaks enumeration over objects using the for...in operator, which in turn breaks lots of other libraries you might want to use later. Sure, this is due to a bug in the core JavaScript spec but it's one we all have to live with.

You're correct, although it's worth noting that you can get around this problem in Rhino (Javascript on the Java VM). Steve Yegge talks about this in his semi-recent talk "Rhinos and Tigers": http://steve-yegge.blogspot.com/2008/06/rhinos-and-tigers.ht...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.