Funktionsaufruf Javascript [duplizieren]
Diese Frage hat hier bereits eine Antwort:
Javascript Funktion Scoping und Heben 15 answersIch habe helloworld aufgerufen und es folgendermaßen definiert:
1) Mit Variable
2) Mit dem Funktionsnamen itseld
var helloWorld = function() {
return '2';
}
function helloWorld() {
return '1';
}
alert (helloWorld()); // This alert 2, but in absence of "var helloWorld = ....", it alert "1".
Kann jemand bitte erklären, warum es var helloWord = aufruft? und nicht funktionieren helloWorld ()?
Danke !