declare and assign all local variables at the beginning of a function to prevent complications due to hoisting
hoisting happens when javascript automatically moves a variable declaration to the top of a function, but doesn't move the value assigned to it, so it defaults the value to undefined
the same rules apply with functions declared inside a function, depending on how they're defined
-----------------------------------------------------------
http://atechapart.com | / alvinsanchez
see my codepens @ http://codepen.io/_asanchez/
On this page of the site you can watch the video online Javascript - How Hoisting Affects Variables and Functions with a duration of hours minute second in good quality, which was uploaded by the user A Tech Apart 05 March 2015, share the link with friends and acquaintances, this video has already been watched 237 times on youtube and it was liked by 4 viewers. Enjoy your viewing!