You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uncaught TypeError: Cannot use 'in' operator to search for 'length' in this is a string
jQuery.each is generating a bug with a string parameter http://prntscr.com/ib9ngg
How to reproduce it
var jEach = function(a){
jQuery.each(a, function(){
console.log(this);
});
};
jEach(null);
jEach([1,2]);
jEach('[1,2]');
jEach('this is a string');
The text was updated successfully, but these errors were encountered:
I know that jQuery.each is supporting an array or an array of objects but by accident instead of using the proper parameter which should be an array in this case, I used a string, so I guess jQuery.each should do nothing here instead of firing an error message.
jQuery in general doesn't validate its inputs, it just relies on them being correct. Adding consistent validation would increase the library size a lot.
If you want such validation, consider using TypeScript which contains jQuery type definitions in the @types/jquery package.
jQuery version
3.1.1
Description
Uncaught TypeError: Cannot use 'in' operator to search for 'length' in this is a string
jQuery.each is generating a bug with a string parameter http://prntscr.com/ib9ngg
How to reproduce it
The text was updated successfully, but these errors were encountered: