mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-14 10:45:06 +02:00
Merge pull request #450 from cubuspl42/master
[JavaScript] Note about how declaring functions affects scope.
This commit is contained in:
@@ -271,6 +271,8 @@ permanent; // = 10
|
|||||||
// outer function's variables, even after the outer function exits.
|
// outer function's variables, even after the outer function exits.
|
||||||
function sayHelloInFiveSeconds(name){
|
function sayHelloInFiveSeconds(name){
|
||||||
var prompt = "Hello, " + name + "!";
|
var prompt = "Hello, " + name + "!";
|
||||||
|
// Inner functions are put in the local scope by default, as if they were
|
||||||
|
// declared with 'var'.
|
||||||
function inner(){
|
function inner(){
|
||||||
alert(prompt);
|
alert(prompt);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user