Skip to content

Instantly share code, notes, and snippets.

@jorotenev
Created October 29, 2017 21:19
Show Gist options
  • Select an option

  • Save jorotenev/d4c879c674d5bddac1df0c8252ddeb93 to your computer and use it in GitHub Desktop.

Select an option

Save jorotenev/d4c879c674d5bddac1df0c8252ddeb93 to your computer and use it in GitHub Desktop.

Revisions

  1. jorotenev created this gist Oct 29, 2017.
    35 changes: 35 additions & 0 deletions example.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    class SomeClass {
    public a;
    public b;
    constructor() {
    this.a = '1';
    this.b = []
    }
    one = () => {
    console.log(`one = () => {} ${this.a}`)
    this.b.push('one')
    }


    two() {
    console.log(`two() {} ${this.a}`)
    this.b.push('two')
    }

    three = function () {
    console.log(`three = funciton() {} ${this.a}`)
    this.b.push('three')
    }
    }

    let someClassObj = new SomeClass();
    someClassObj.one()
    someClassObj.two()
    someClassObj.three()
    console.log(someClassObj.b)

    // Outputs
    // one = () => {} 1
    // public two() {} 1
    // three = funciton() {} 1
    // ["one", "two", "three"]