Handle Array change event, add action listener to array change - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

Handle Array change event, add action listener to array change

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() {// ww  w . ja  va 2  s.c o m
var MyArray = function() {
    var arr = [];
    arr.push = function() {
        console.log("PUSHING", arguments);
        return Array.prototype.push.apply(this, arguments);
    }
    return arr;
};
var arr = new MyArray;
arr.push(12, 3, 45);
console.log(arr, arr[2]);
    });

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

Related Tutorials