DEV Community

Cover image for ⚡️⛓JavaScript Visualized: Scope (Chain)

⚡️⛓JavaScript Visualized: Scope (Chain)

Lydia Hallie on November 20, 2019

Time for the scope chain 🕺🏼 In this post I assume you know the basics of execution contexts: I’ll soon write a post on that too though 😃 Let's ...
Collapse
 
evanbacon profile image
Evan Bacon

Hey @theavocoder

Collapse
 
lydiahallie profile image
Lydia Hallie

hi @baconbrix @evanbacon

Collapse
 
lydiahallie profile image
Lydia Hallie

how are you doing sir @baconbrix @evanbacon

Collapse
 
evanbacon profile image
Evan Bacon

Hi the @avocoder me again.

I have a (REALLY (INMPORTANT)) question for you 🤭😊

Thread Thread
 
evanbacon profile image
Evan Bacon

like really imporaant

~ Evan (baconbrix (like and subscribe)) bacon 🥓

Thread Thread
 
lydiahallie profile image
Lydia Hallie • Edited

ask

the

i

m

p

o

r

t

a

n

t

questionee @baconbrix @evanbacon

Thread Thread
 
evanbacon profile image
Evan Bacon

OK

Thread Thread
 
lydiahallie profile image
Lydia Hallie

tik tok im waiting

Thread Thread
 
evanbacon profile image
Evan Bacon

So I was following you on insagtarm 😛 then I think I saw u on medium 🥳🤩 and finally I opened a PR on ur javascript questions 😤

Thread Thread
 
evanbacon profile image
Evan Bacon

my question is u r good at javascript and you also use coffeescript (LMAAO) but why does your descriptioon say you live in florida switzerland and amsterdam?!

Thread Thread
 
lydiahallie profile image
Lydia Hallie

ok so.

so like. first like, i live in like, amsterdam 🍃 then like, like i live in florida 🐬but like, also i like live in like sweden

Thread Thread
 
evanbacon profile image
Evan Bacon

NEAT

Thread Thread
 
evanbacon profile image
Evan Bacon • Edited

ANWAYS , whatss you ## (🤭☎️) because i have , another few question for y o u to answer me to

and wat is ansewr


foo + bar = c

var foo = bar

{
  c++
  // (LOL)
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
lydiahallie profile image
Lydia Hallie

discuss

Thread Thread
 
lydiahallie profile image
Lydia Hallie • Edited

isnt this the H.T.M.L. programming code ? ? ?

Collapse
 
rizuwan86 profile image
rizuwan86

thank you

Collapse
 
nickytonline profile image
Nick Taylor

These are all great articles you've created here.

Just FYI, in case you weren't aware, you can link them together using a series so that people can find your past ones as well.

Looking forward to your next article!

Multiple TV and movie characters giving a thumbs up

Collapse
 
adityavardhan profile image
N.Adityavardhan

hi , lydiahallie @theavocoder, i like the way you choose to share knowledge , can you please suggest me how can you do that animations for better understanding, could you please suggest me for how can i do like that animations in windows 8 PC any tools are available for windows or tools or chrome extensions ??

Collapse
 
bigleegeek1 profile image
bigleegeek1

newbie to learning JS. your posts are very clear and informative. your Final JS Notes will be invaluable to others just starting out. look forward to future posts.

bigleegeek

Collapse
 
sudarshan_rayate profile image
Sudarshan Rayate

Hey @lydiahallie

let a = 11;
{
var a = 21;
}
Why this code snippet shows "SyntaxError: Identifier 'a' has already been declared "
and following code run as normal

var a = 11;
{
let a = 21;
}

Collapse
 
krishnagk9964 profile image
KRISHNA K
  • var is function scoped that is it is declared at top of the nearest function scope, global scope in the first one, where already a is present .
  • let is block scoped that is it is scoped inside nearest flower brackets.
  • in second case var a is in global scope and let a is in block scope.
Collapse
 
augustoaraujoo profile image
Augusto Araujo da Rocha

muito bom , ou seja meu escopo que seria minha função declarada com "chaves"
const a = 'hi'
function myFunction() {
// pode ter acesso a todos que estão de fora da minha função
const x = 'ana'
console.log(a) -> 'hi'
}
// mas quem está de fora não consegue acessar os valores de dentro da minha função
// console.log(x) -> undefined

Collapse
 
ericwu91 profile image
EricWu91

Another awesome content! Thanks!

Collapse
 
codermonkey profile image
Shihabudheen US

Great article. I guess you missed to mention, var has function scope.

Collapse
 
realpchauhan profile image
Pradeep Chauhan

Hi @theavocoder how can i learn and strong my fundamental javascript and advance javascript. please share resources.

Collapse
 
evanbacon profile image
Evan Bacon

Does the same methodology apply to telescopes 🔭

Collapse
 
lydiahallie profile image
Lydia Hallie

u need a microscope

Collapse
 
ikemkrueger profile image
Ikem Krueger • Edited

You introduced the "local scope chain", "activation object" and "global object". What has that to do with the "local execution context"?

Collapse
 
tpostolyuk profile image
tpostolyuk

Really useful information!

Collapse
 
chhabraboy profile image
Anurag Chhabra

You're a life saver , that was dope content 🔥🔥

Collapse
 
gabrielduerto profile image
Gabrielduerto

esto es una JOYA, que buena explicación

Collapse
 
nandansn profile image
Nandakumar R

thanks