i have the following html:
<body>
<div >
<h1>OnlineList</h1>
<ul id="onlineList">
<li con="123" age="10">Test A</li>
<li con="234" age="11">Test B</li>
<li con="345" age="10">Test C</li>
<li con="456" age="12">Test D</li>
</ul>
</div>
</body>
and i am using jquery as following:
var meow = [];
var meow2 = [];
var a = $("li").each(function ()
{
meow.push( $(this).attr("age"));
});
var b = $("li").each( () =>
meow2.push( $(this).attr("age"))
);
console.log(meow);
console.log(meow2);
meow will give me the expected output:
["10", "11", "10", "12"]
meow2 will give me:
[undefined, undefined, undefined, undefined]
I'm little bit suprised what happend cause i just use an anonymous/arrow function?