I was searching in stackoverflow and the web, could not get proper results or explanation siting difference between these three methods.
As far as i understand, the
bind creates a new function with the same function body and then returns the new function
call calls the same function in a different passed context and the parameters have to be explicitly written
apply calls the same function in a different passed context but the parameters have to be passed in a an array
var f = function(p1, p2) {
var s = this;
}
var newFunc = f.bind(window, 1, 2);
// here newFunc is a function which when you will call will have this as window and p1 = 1 and p2 = 2
f.call(window, 1, 2);
// by executing this line this = window p1 = 1 and p2 = 2
f.call(document, 2, 3);
// by executing this line this = document p1 = 2 and p2 = 3
f.apply(window, [1, 2]);
// by executing this line this = window p1 = 1 and p2 = 2