Skip to content
On this page

호이스팅(hoisting)

Title
호이스팅(hoisting)
Category
JavaScript
Tags
Aliases
호이스팅(hoisting)호이스팅hoisting
Related
Created
2 years ago
Updated
last year

Example

js
function fn() {
	foo = 123;
}

fn();

console.log(foo); // foo is not defined

(function () {
	bar = 123;
})();

console.log(bar); // 123

(function () {
	var baz = 123;
})();

console.log(baz); // baz is not defined
function fn() {
	foo = 123;
}

fn();

console.log(foo); // foo is not defined

(function () {
	bar = 123;
})();

console.log(bar); // 123

(function () {
	var baz = 123;
})();

console.log(baz); // baz is not defined

References

Released under the MIT License.