jQuery.each for lists and non-lists
- by Brian M. Hunt
I've a jQuery.each(data, foo), where data is either a string or a list of strings. I'd like to know if there's an existing utility function to convert the string to a list, or otherwise perform foo on just the string. So instead of the easy route:
if (!$.isArray(data)) {
foo(0, data); // can't rely on `this` variable
} else {
$.each(data,foo);…