Compare elements positions in first array with another array - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

Compare elements positions in first array with another array

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  . j av a  2 s. c o  m
var a = ["1","2","3","4","5"];
var d = ["1","2","3","5","4"];
function checkArrays( arrA, arrB ){
    for(var i = 0; i < arrA.length; i++) { if(arrA[i] !== arrB [i]) return arrB [i] };
}
console.log(checkArrays(a, d));
    }

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

Related Tutorials