javascript - js Uncaught RangeError: Maximum call stack size exceeded -
var = { fun:function(){ alert(1); } } a.fun = function(){ a.fun(); alert(2); } a.fun();
i want change function a.fun call origin one
if looking override existing function , call original function overridden instance, need store reference old method like
var = { fun: function() { snippet.log(1); } }; (function(a) { var old = a.fun; a.fun = function() { old.apply(this, arguments); snippet.log(2); } })(a); a.fun();
<!-- provides `snippet` object, see http://meta.stackexchange.com/a/242144/134069 --> <script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>
Comments
Post a Comment