Opened 10 years ago
Closed 10 years ago
#13822 closed bug (notabug)
jQuery.each(not array/object, callback) throw an error
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I know that jQuery.each() has created to work with array and objects, but if you expect some AJAX response, maybe you can receive another type of result. A good programmer can check the result by a valid type, but it can be a big problem if you pass a non array/object to jQuery.each. You too receive variable type of results depending of type, and too, throw an error.
Make a check: http://jsfiddle.net/3EGA6/1/
If affect ALL jQuery versions.
Some observations:
- v1.9.1 (stable/edge) and v2.0.0 (stable/edge) are same;
- v1.8.3 and v1.7.2 accepts strings, splitting it to array;
- v1.6.4 causes strange things to undefined or null types;
- All browser have the same results;
Note: See
TracTickets for help on using
tickets.
It's documented to work the way it works, and it works reasonably. Don't pass garbage to the API, we don't guarantee consistent results with garbage.
Please be a good programmer.