The This keyword

node v10.16.3
version: 1.0.0
endpointsharetweet
var me = { name: "Tyler", age: 25, sayName: function(){ console.log(this) } }
var sayNameMixin = function(obj){ obj.sayName = function(){ console.log(this.name) } } var me = { name: "Tyler", age: 25, } var joe = { name: "Joe", age: 23, } sayNameMixin(me) sayNameMixin(joe) joe.sayName() me.sayName()
Loading…

no comments

    sign in to comment