0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScript Hoisting メモ

Posted at

#Hoistingとは
JavaScriptは変数宣言は必要がありません、自動的に変数名を設定されます。

example1.js

var a = 12;
console.log(a);//12

a = 12;
console.log(a);//12

example2は同じ結果になります。こられはhoistingということです。

example2.js

var a;
a = 12;
console.log(a);//12

a = 12;
console.log(a)//12
var a;

example3は無名と名つけ関数のHoistingの事例です。

example3.js
function a(x,y){
  return x+y;
}
console.log(a(x,y));//5

var b = function (x,y){
  return x+y;
}

console.log(b(2,3));//5


c = function (x,y){
  return b+c;
}

console.log(c(2,3));//5
var c;

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?