Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var func1 = function() {
- // console.log(this.source1); // wont work, makes sense
- // console.log(source1); // wont work, wish it would
- console.log(this.source2); // works fine
- console.log(source2); // works fine
- };
- var func2 = function() {
- var source1 = "source1";
- this.source2 = "source2";
- func1.call(this);
- }();
- var func3 = function() {
- var source3 = "source3";
- var func4 = function() {
- console.log(source3); // also works fine, makes sense
- }();
- }();
- var module = (function() {
- var source1;
- var source2;
- var func1 = function() {
- console.log(source2); // works fine
- };
- var func2 = function() {
- source1 = "source1";
- }();
- var func3 = function() {
- var func4 = function() {
- console.log(source1); // also works fine, makes sense
- }();
- }();
- return {
- func1: func1,
- func2: func2,
- func3: func3
- };
- }());
- // Then invoke them.
- module.func2();
- module.func1();
- var func1 = module.func1;
- var func2 = module.func2;
- var func3 = module.func3;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement