Check this to if it is set to current object inside array.prototype.reduce() - Javascript Array

Javascript examples for Array:reduce

Description

Check this to if it is set to current object inside array.prototype.reduce()

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   www.ja v a2  s.com
function callback(previous,current,index,array){
    console.log(this);
    return previous+current;
}
[1,2,3,4,5].reduce(callback);
var myObject = {};
[1,2,3,4,5].reduce(callback.bind(myObject));
    }

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

Related Tutorials