Variable declaration

Hi!
I noticed that when declaring a variable, the syntax requires a keyword (at the beginning of the sequence or script), but when the variable is reassigned, keywords sometimes disappear. Some other times, keywords are used within a block.

Question: where/when are keywords used? There must be a logic to that, right?
Thanks for your help.

So these links Might help:

How to declare variables:

Variables scopes:

Thank you.
This answers partly my question (unless I have completely misread the info).

Say, I have these statements:

var x =4;
console.log(x); //Output is ‘4’

but if I try
y = 3; //omitting ‘var’
console.log(y); //Output is ‘3’ too - despite that I didn’t use the var statement when assigning a value to my ‘y’ variable

Question is then - why use a statement (like var or let) in the first place, if variables are recognized without as well?!

Because code that works and good code are not the same thing.

the keyword says something about the scope, and in a few lessons time you will learn about blocks and functions, and then the variable scope comes more into play more

this is something which you will occur during learning, a concept might become clearer when combined with other things you learn

Thank you for taking the time to answer.
It must sound silly to someone who’s an expert, but I needed to understand the underlying logic.
Have a good day! -M

Envoyé de mon iPhone