--- title: Hoisting slug: Glossary/Hoisting tags: - CodingScripting - Glossary - JavaScript translation_of: Glossary/Hoisting ---
{{Glossary("Function", "Functies")}} en {{Glossary("Variable", "variabelen")}} zijn hoisted (letterlijk: "getakeld" of "omhoog gehesen") in {{Glossary("JavaScript")}}. Hoisting is het gedrag in JavaScript waarbij declaraties naar het begin van een {{Glossary("scope")}} verplaatst worden (globale scope of de scope van de huidige functie).
Dit betekent dat men een functie of een variabele kan gebruiken vooraleer ze gedeclareerd is. Met andere woorden: een functie of een variabele kan geclareerd worden nadat ze al is gebruikt.
Variabelen:
foo = 2 var foo; // wordt impliciet begrepen als: var foo; foo = 2;
Functies:
hoisted(); // logt "foo" function hoisted() { console.log("foo"); }