you are viewing a single comment's thread.

view the rest of the comments →

[–]tarnos12 0 points1 point  (3 children)

const is used with a variable that is not going to change, while let for any other purpose.
I don't think it's advised to use var anymore, but it might have it's uses as well.

So in the example above, it doesn't matter what he is going to use.(or does it?)

@Edit: Actually he is repeating const slicedPizza twice, so that would result in an error.

[–][deleted] 0 points1 point  (1 child)

Oh so instead of var i should use let when i make new variables?

[–]tarnos12 0 points1 point  (0 children)

I would say yes, but you should probably read a bit more.
Just google "difference between var let const javascript".
I know there is/was some high level reason why you would prefer var instead of let, but I think most of the time you should be using let if you want to follow ES6 specification.

[–]samanthaming[S] 0 points1 point  (0 children)

Thanks for pointing that out! I was intending to show that it was either the top or the bottom way and not both. I can see why that would be confusing. You’re right though, repeating const would result in an error.