Skip to main content

Bug Tracker

Side navigation

#13822 closed bug (notabug)

Opened April 25, 2013 06:19PM UTC

Closed April 25, 2013 06:21PM UTC

jQuery.each(not array/object, callback) throw an error

Reported by: david.proweb@gmail.com 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;
Attachments (0)
Change History (1)

Changed April 25, 2013 06:21PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

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.

A good programmer can check the result by a valid type,

Please be a good programmer.