1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-20 05:21:26 +02:00

Note about how declaring functions affects scope.

This commit is contained in:
cubuspl42
2013-12-14 14:41:07 +01:00
parent 48d9eecbfd
commit 432eb6f53d

View File

@@ -271,6 +271,8 @@ permanent; // = 10
// outer function's variables, even after the outer function exits.
function sayHelloInFiveSeconds(name){
var prompt = "Hello, " + name + "!";
// Inner functions are put in the local scope local by default, as if they
// were declared with 'var'.
function inner(){
alert(prompt);
}