@@NetNinja I learned HTML/CSS AND JavaScript from your page with 0 knowledge of coding! I am recommending you to everyone I know. You deserve more recognition.
with let statement, each time for loop iterates, it stores x value to the its own spot in memory. and whenever callback function .onclick is invoked, it knows the spot and the value inside of it. its called closure
Hey, I didn't understood why the value persisted? We didn't created any closer here, still the value of x when defined using `let` acts like we did clouser. How that works?
@The Net Ninja hi, i still dont understand how is it that when you use var to declare, the output when you click a list item is 4. I don't understand the process that leads to that output.
Thank you for your work, but I still don't understand the difference between the var keyword and the let keyword In the loop. Why is it going such way?
Excellent tutorial, but has no sense have at 04:37 "x" how global scope. It should be a local variable for the "for" block. Seems "let" is the workaround to resolve this explicitly
In this specific case you would create a closure when attaching the onclick event. An example way to do this: jsbin.com/jorihikege/edit?html,js,console,output In this example I've named the local variable 'localX', but it would work perfectly with just 'x' everywhere.
content from 8 years ago, and this is still very easy to comprehend and useful! Thank you!
Glad it was helpful! :)
@@NetNinja I learned HTML/CSS AND JavaScript from your page with 0 knowledge of coding! I am recommending you to everyone I know. You deserve more recognition.
Wasn't it supposed to log 'undefined' because the variable no longer exists after the for loop is over?
That bothers me as well
I still dont understand how numbers are saved to th functions in the loop anyway please help!
with let statement, each time for loop iterates, it stores x value to the its own spot in memory. and whenever callback function .onclick is invoked, it knows the spot and the value inside of it. its called closure
Hey, I didn't understood why the value persisted?
We didn't created any closer here, still the value of x when defined using `let` acts like we did clouser. How that works?
@The Net Ninja hi, i still dont understand how is it that when you use var to declare, the output when you click a list item is 4. I don't understand the process that leads to that output.
Nice tutorials, And that ninja screams so loud.
hate it!!!!!
In lexical scope, how is x value ,when logged to console, not overwritten each iteration loop?
You explain so well bro.. thanks
Very clear . Thanks
i have to watch it again ^^
What would happen to the number result in console if you clicked the numbers in the order of 3 2 1 0 instead of going up 0123?
Thank you for your work, but I still don't understand the difference between the var keyword and the let keyword In the loop. Why is it going such way?
Great details, keep going. :)
How did you making your Brackets linter to stop showing linting warnings about Es6?
Great!!! Thanks for help!!!
Excellent tutorial, but has no sense have at 04:37 "x" how global scope. It should be a local variable for the "for" block. Seems "let" is the workaround to resolve this explicitly
So how did js deal with this before the let keyword was introduced?
In this specific case you would create a closure when attaching the onclick event. An example way to do this: jsbin.com/jorihikege/edit?html,js,console,output In this example I've named the local variable 'localX', but it would work perfectly with just 'x' everywhere.
Thank you Mateusz.
or you can put the for loop in a separate function and call it everytime someone clicks li.
I don't suppose you can do a framework tutorial and how to upload to a server?
+Anatole Navarro Hey - will take a look at this towards the end of the series!
SAVE ME NET NINJA!