#12130 closed bug (duplicate)
jQuery.each on object with length element.
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I think jQuery.each should check for length to be present and an integer, rather than just checking for it’s existance.
The innocent Object { "length":"33", "text":"foo" } can’t be used with $.each.
Change History (6)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:5 Changed 11 years ago by
I realize a 'fix' would not work for everybody. But a new function $.foreach and deprecating $.each might be doable.
We have so many JSON users who could be bitten by this 'bug'
comment:6 Changed 11 years ago by
You said it yourself, a "fix" wouldn't work for everybody. The trick here is that you should probably not use words like "length" or "nodeType" as properties of your object.
Note: See
TracTickets for help on using
tickets.
It came up on the forum http://forum.jquery.com/topic/parsejson-gotcha-with-reserved-words#14737000003512366