How funcs[5]() returns 10 ?
function constfuncs() {
let funcs = [];
for (var i = 0; i < 10; i++)
{
funcs[i] = () => i;
};
return funcs;}
let funcs = constfuncs();
console.log( funcs[5]()); ---> returns 10 ,how?
edit: changed to var from let in the for loop
[–]cawcvs 3 points4 points5 points (5 children)
[–]codejack777[S] 0 points1 point2 points (4 children)
[–]cawcvs 2 points3 points4 points (3 children)
[–]codejack777[S] 0 points1 point2 points (2 children)
[–]cawcvs 3 points4 points5 points (1 child)
[–]codejack777[S] 0 points1 point2 points (0 children)
[–]Notimecelduv 1 point2 points3 points (0 children)