Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢

Eunkwang Shin gracefullight

🐢
View GitHub Profile
@gracefullight
gracefullight / global-variables-are-bad.js
Last active Feb 17, 2021 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
View global-variables-are-bad.js
// var 로 내부 변수를 선언해야합니다.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// 그렇지 않으면 전역변수로 선언됩니다.
(function() {
foo = 'Hello, world!';
print(foo) //=> Hello, world!