JQuery: conversion from string type to string object in $ .each

$.each(["foo","bar"],function(){console.debug(this);});

converts "foo" and "bar" of a string type to their equivalent in a string object.

while...

$.each(["foo","bar"],function(i,e){console.debug(e);});

will store "foo" and "bar" in the original string type.

I wonder why $ .each does the conversion? And, moreover ... if this conversion never happens - leave the strings as they are, whether they are a string type or a string object?

+3
source share
2 answers

jQuery : JavaScript. 10.4.3 ECMAScript Third Edition, , - this: , (window), - :

3) , Type (thisArg) , ThisBinding ToObject (thisArg).

, () .

JavaScript, , , Netscape , ECMAScript. Strict Mode .

+1

jQuery documentation:

( , Javascript , .)

, Javascript, jQuery, .

jQuery , , .

+2

All Articles