override called function in javascript - Javascript Function

Javascript examples for Function:Function Argument

Description

override called function in javascript

Demo Code

ResultView the demo in separate window

<html>
   <head>
      <script>
    function MyClass() {/*from www. j  a v a2s .c  o m*/
        function someFunc() { 
           this.calledFunc(); 
        }
        function calledFunc() { 
           document.writeln('orig called'); 
        }
        return {
            someFunc: someFunc,
            calledFunc: calledFunc
        }
    }
    var obj = new MyClass();
    obj.someFunc();
    obj.calledFunc = function() { 
       document.writeln("not orig called"); 
    }
    obj.someFunc();

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

Related Tutorials