#Window Global Object clarification

8 messages · Page 1 of 1 (latest)

charred shore
#

Just need a quick clarification on what the use case of a window global object would be?
What is the difference between declaring

a = 'Something';
b = 'Something else';

and doing

const a = 'something';
// or 
let a = 'Something';
#

If I got it right, would it be just a variable that can be used and modified inside functions?

vale barn
#

When you don't use let or const the variable is scoped globally and so is accessible anywhere in your code. If you use let or const the variable is only accessible inside of the current scope and any scopes nested in that scope.

charred shore
#

Oh, that makes sense

#

Just one more quick question, using var, it only scopes to functions right?

#

And not to blocks

vale barn
#

Yeah

charred shore
#

All right! Thanks!