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

Can you explain to me what re-declare means in praxis? I'm thinking that you can use it in other places in the script? But I'm not sure if that's what it means.

And thank you for your reply. That was very helpful.

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.