Skip to content

Instantly share code, notes, and snippets.

@imbcmdth
Created October 12, 2012 21:35

Revisions

  1. imbcmdth revised this gist Oct 12, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    // test is global..
    // current scope is global..

    function Test(n) {
    this.test = n;

  2. imbcmdth revised this gist Oct 12, 2012. 1 changed file with 11 additions and 6 deletions.
    17 changes: 11 additions & 6 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,18 @@
    // test is global..
    var test = {
    test: 5,
    fn: function (n) {
    (function () {
    function Test(n) {
    this.test = n;

    var bob = function (n) {
    this.test = n;
    }());
    };

    this.fn = function (n) {
    bob(n);
    return this.test;
    }
    };
    }

    var test = new Test(5);

    // What does this return
    test.fn(1);
  3. just2n created this gist Oct 12, 2012.
    16 changes: 16 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // test is global..
    var test = {
    test: 5,
    fn: function (n) {
    (function () {
    this.test = n;
    }());
    return this.test;
    }
    };

    // What does this return
    test.fn(1);

    // And this?
    test.fn(2);