DEV Community

Discussion on: A common language feature I never learned about in college

Collapse
 
grglldz profile image
Guiorgui

You might want to use let or const keywords because var will bubble up to the function block since it's the only block var recognizes as a scope

Collapse
 
winstonpuckett profile image
Winston Puckett

You know, it's funny. I originally included JS examples as well but then wasn't sure 100% sure how scoping worked. I appreciate knowing now :)

Collapse
 
faizan profile image
Faizan Akram Dar

This is not JavaScript 🤷‍♂️

The initial function declares a void return type which sure isn't a JavaScript thing

Collapse
 
grglldz profile image
Guiorgui

You're right! I just read the function body. I'll show myself out...

Thread Thread
 
faizan profile image
Faizan Akram Dar

Haha 😁