MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

巻き上げ(ホイスティング)

この翻訳は不完全です。英語から この記事を翻訳 してください。

Hoisting is a term you will not find in the JavaScript docs. Hoisting was thought up as a general way of thinking about how execution context (specifically the creation and execution phases) work in JavaScript. But, hoisting can lead to misunderstandings. For example, hoisting teaches that variable and function declarations are physically moved to the top your coding, but this is not what happens at all. What does happen is the variable and function declarations are put into memory during the compile phase, but stays exactly where you typed it in your coding.  

詳細情報

技術的な例

One of the advantages you get from JavaScript putting function declarations into memory first, before it executes any coding, is this allows you to use a function before you declare it in your coding. For example:

function catName(name) {
  console.log("My cats name is " + name);
}

catName("Tigger");
/*
The results of the coding above is: "My cats name is Tigger"
*/

The above coding is how you would expect to write the coding for it to work. Now, lets see what happens when we call the function in our coding before we write it:

catName("Chloe");

function catName(name) {
  console.log("My cats name is " + name);
}
/*
The results of the coding above is: "My cats name is Chloe"
*/

技術リファレンス

ドキュメントのタグと貢献者

 このページの貢献者: chikoski, keioka, hurumeki
 最終更新者: chikoski,