The difference between call() and apply():
Similarities:
Both () and apply() can be used to indirectly call functions, and both can explicitly call this required. That is, any function can be called as a method of any object.
2. Both methods can specify the call parameter.
the difference:
The basic difference between call() and apply() is to pass parameters to functions.
call(): Use its own list of arguments as the function's parameters;
apply(): requires that parameters be passed in as an array.
function track(o,m){ var original =o[m]; o[m] =function( ){ (new Date(),m); var results =(this,arguments); (new Date(),m); return results; } }
Their usage can be explained by the given example:
<script> var someObject = { myProperty:'Foo', myMethod:function (prefix,posfix) { (prefix + + posfix); } }; ('<','>');//Foo var someOtherObject = { myProperty:'Bar' }; (someOtherObject,'<','>');//Bar (someOtherObject,['<','>']);//Bar </script>
The above is a detailed explanation and integration of the difference between call() and apply() in javascript introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!