This project is archived and is in readonly mode.

#790 ✓invalid

Use hasOwnProperty in foreach loops

Reported by Xandros | November 18th, 2009 @ 02:58 PM | in 2.0 (closed)

Use hasOwnProperty in foreach implementation to protect this function from outside code that migh have messed with object prototypes.

See section "Code in a vacuum" on

Comments and changes to this ticket

  • Jan Kassens

    Jan Kassens November 21st, 2009 @ 06:29 PM

    • State changed from “new” to “invalid”

    We see a serious performance hit doing an additional function call for each and every item we iterate. If someone wants to track down the places where is used in critical parts and do a benchmark it'd be great. For now we're on the "extending Object.prototype is verboten" side, since it would also break 3rd party code using w/o hasOwnProperty.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket