Bug Tracker

Opened 6 years ago

Closed 6 years ago

#14566 closed bug (notabug)

each function does not check object is iterable

Reported by: me@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.1
Keywords: Cc:
Blocked by: Blocking:

Description

$.each(obj, function(index, value){
    alert(index);
});

If obj is not an Array or not a String or not an Object, it will raise an error like "Uncaught TypeError: Cannot read property 'length' of undefined ".

I think before define "length=object.length" will check object type.

Change History (1)

comment:1 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

That would make debugging harder if we covered up mistakes. Pass in valid arguments.

Note: See TracTickets for help on using tickets.