Another method for finding the context of a function is by looking for the new
keyword. If a function is called and is preceded by the new
keyword, it will have its own context. It will not default to the global context, and it doesn't need to be called as a method on an object or with .call
, .apply
, or .bind
.
For more information on this
in JavaScript, go read this blog post.