Let vs var vs const
Can any one help me understand how these three different ways to create a variable really works within a function?
From what i already learn var is functions scoped let and const is block scope. Whats confusing to me is does this mean that if I create a variable using var I can use that variable anywhere inside the function and let/const can only be used within a specific block for example a if/switch statement?
Also how do you even know when its the right time to use a specific type of variable?
Thanks in advance
From what i already learn var is functions scoped let and const is block scope. Whats confusing to me is does this mean that if I create a variable using var I can use that variable anywhere inside the function and let/const can only be used within a specific block for example a if/switch statement?
Also how do you even know when its the right time to use a specific type of variable?
Thanks in advance
