robertsosinski / tutorial-scope-in-javascript

Code to accompany my "Binding Scope in JavaScript" tutorial

This URL has Read+Write access

tutorial-scope-in-javascript / example-3.js
100644 19 lines (13 sloc) 0.269 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// example-3.js
 
window.name = "window";
 
object = {
  name: "object",
  
  action: function() {
    nestedAction = function(greeting) {
      console.log(greeting + " " + this.name);
    }
    
    nestedAction("hello");
  }
}
 
object.action("hello");
 
// hello window