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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -