-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bd49916
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 作用域对接 | ||
|
||
function foo(a) { | ||
var b = 2; | ||
// some code | ||
function bar() { | ||
// .. | ||
} | ||
// more code | ||
var c = 3; | ||
} | ||
|
||
bar() | ||
|
||
console.log(a, b, c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function doSomething(a) { | ||
b = a + doSomethingElse(a * 2) | ||
|
||
console.log(b * 3); | ||
} | ||
|
||
function doSomethingElse(a) { | ||
return a - 1; | ||
} | ||
|
||
var b; | ||
|
||
doSomething(2); | ||
|
||
|
||
// more reesonable | ||
function doSomething(a) { | ||
function doSomethingElse(a) { | ||
return a - 1; | ||
} | ||
|
||
var b; | ||
b = a + doSomethingElse(a * 2); | ||
console.log(b * 3); | ||
} | ||
|
||
doSomething(2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var MyReallyCoolLibrary = { | ||
awesome: "stuff", | ||
doSomething: function () { | ||
|
||
}, | ||
doAnotherThing: function () { | ||
|
||
} | ||
} | ||
|
||
console.log(MyReallyCoolLibrary.awesome) | ||
console.log(MyReallyCoolLibrary.doSomething) | ||
console.log(MyReallyCoolLibrary.doAnotherThing) | ||
|
||
|
||
var a = 2; | ||
function foo() { | ||
var a = 3; | ||
console.log(a); | ||
} | ||
console.log(foo()); | ||
console.log(a); |