Managing Scope Using Call, Apply, and Bind
by Aaron Crowder on
Call Calls a function, with the specified arguments passed in The first argument becomes this, the rest are passed in as regular arguments. Using call allows you to maintain the scope of this accross methods. It works like this: Here we're using prototypical inheritance to allow us to inheirit properties from Animal in Dog and Cat. Using call allows us to invoke Animal to initialize it's properties while maintaining the correct scope. Apply Calls a function, with the specified arguments pas...
Read more...