Class.method = function () { this.xx }
Class.prototype.method = function () { this.xx }
var clazz = new Class();
clazz.method();
When I call the 4th line this in the function will refer to clazz
But when Class.method() is executed, what will this refer to?
thiswithin theClass.prototype.methodfunction will still refer to theClassinstance. This isn’t a static method, a static (i.e. one per class) method would be something like:For example: