Insert scripts into an existing function - Javascript Function

Javascript examples for Function:Function Definition

Description

Insert scripts into an existing function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*from   w  w  w.  ja  va2 s.  co m*/
var cool = {
    lol: function() {
        console.log("test");
    }
}
var ori = cool.lol;
cool.lol = function() {
    ori();
    console.log('my test');
}
cool.lol();
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials