There is no difference with the function itself, but the latter gives you great flexibility, since you have a link to the function, and it is different from how it behaves if it is overwritten.
This allows you to achieve behavior with the latter, which you cannot achieve with the former; such as the following trick to "override" an existing function and then call the "base":
var myOriginalFunction = function() { window.alert("original"); } var original = myOriginalFunction; var myOriginalFunction = function() { window.alert("overridden"); original(); } myOriginalFunction();
This gives you the warning "overridden", followed by the warning "original".
However, if you try to do this with the previous entry, you will find that you are stuck in an endless "overidden" warning loop.
source share