Override A Function In Javascript - Javascript Function

Javascript examples for Function:Function Definition

Description

Override A Function In Javascript

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//  w w  w . j  av a 2 s  .c om
var d = new Date();

$("#d1").text(d.getFullYear());

Date.prototype.getFullYear = function() { return "Full Year"; }

$("#d2").text(d.getFullYear());

    });

      </script> 
 </head> 
 <body> 
  <div id="d1"></div> 
  <div id="d2"></div>  
 </body>
</html>

Related Tutorials