When looking at the source code for raphael or g.raphael or other libraries I\'ve noticed the developer does something like this:
var val = Math.max.apply(Ma
Why invoke “apply” instead of calling function directly? Let's have a snippet:
var obj = {a: "apply"};
func.call(obj, "parameter");
function func(para) {
if(this.a === "apply"){
console.log('apply');
}
}
Here we can see we are using 'this' (context) within a function, If we directly call a func than we don't have any context, than it will take window context, which is wrong. So, if you are using context within your function than use apply method.