Skip to content

Instantly share code, notes, and snippets.

@chez14
Last active March 24, 2018 09:31
Show Gist options
  • Save chez14/9c702be3e586e10ae72961c14c5e3390 to your computer and use it in GitHub Desktop.
Save chez14/9c702be3e586e10ae72961c14c5e3390 to your computer and use it in GitHub Desktop.

ES2K15 this

const benda = {
    a: function() {
        this.v_a = 1;

        let x = {
            count_va: () =>{ // notice here, we're using () => {...}
                return this.v_a;
            }
        }

	return x.count_va();
    }
}
benda.a() // 1.
const benda = {
    a: function() {
        this.v_a = 1;

        let x = {
            count_va: function() { // notice here, we're using function() {...}
                return this.v_a;
            }
        }

	return x.count_va();
    }
}
benda.a() // undefined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment