4 ms·
`this` in javascript is tied to whatever object is calling it. For `User.getCount`, the object is User, but when you declare `func = User.getCount`, and then ca
by swang 11y ago
`this` in javascript is tied to whatever object is calling it. For `User.getCount`, the object is User, but when you declare `func = User.getCount`, and then call `func()`, you are now calling from whatever object `func` belongs to (in this case, the "global" object)