Let's review the various ways to call a function that we have encountered:
- Function-style when unbound (
fun(arg1, arg2)
)this
is set to the global context (global
orwindow
)
- Method-style (
obj.method(arg1, arg2)
)this
is set toobj
- Constructor-style (
new ClassName(arg1, arg2)
).- Creates a new, blank object.