Confused on prototype bindings, this statement
问题 In the following code, I'm wondering how context is bound to this : In obj.myMethod(); , context is given to the object. So logging it gives the object. In var myFun = obj.myMethod; then myFun(); , context is given to the Window. The only difference is you're setting the function to a variable. var obj = { myMethod : function () { console.log(this); //'this' is bound to context of object } }; obj.myMethod(); //calling object property directly = Object {myMethod: function} var myFun = obj