js bid,call,apply code example

Example 1: bind in javascript

bind() returns a bound function that, when executed later, will have the correct context ("this") for calling the original function.

Example 2: call() vs apply() vs bind()

Differentce between .bind() , .call() and .apply()

.bind(someobj) -> does not invoke the function, it just allows you to 
bind whatever object you want, you have to call the function yourself.

.call(someobj) and .apply(someobj)-> both invoke the function 
immediately,and modify the context. 
The only difference is how you pass your
own arguments. See below

.call(someobj, param1, param2)
.apply(someobj, [param1, param2]) //uses array to pass the args