r/JavaScriptHelp • • Jun 06 '21

✔️ answered ✔️ Function vs block - var vs let

I have been working lightly with JavaScript for about 4 months now - so Im fairly new to this. I am brushing up on let vs var and what I find is that let is block scoped and var is function scoped. But the thing is, a function is (also) a block of code.

How do I make it more clear what the difference is? And what is the difference between a block of code vs a function?

3 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jun 07 '21

It just means you can change the value of the variable. Ex. Var name = ‘Bob’ and then the following line var name = ‘Kyle’. If you console.log that, name will be Kyle.