javascript - For loop error in Firefox and IE but not Chrome -


i have weird issue: have loop in javascript works absolutely expected in chrome not in firefox or ie. in firefox , ie adds undefined item array , have no clue why.

angular.module('app', [])  .controller('itemctrl', function($scope){     $scope.itemsa = [         { name: 'testa' },         { name: 'testb' }     ];     $scope.itemsb = [];      $scope.dosomething = function(idparam) {         for(var = 0; < $scope.itemsb.length; i++){             if ($scope.itemsb[i].name === $scope.itemsa[idparam].name) { ... }; }; 

according developer tools in both browsers $scope.itemb has length 0 @ loop start line for(var = 0; < $scope.itemsb.length; i++) (for whatever reason) still starts loop (which shouldn't know) , in following line if ($scope.itemsb[i].name === $scope.itemsa[idparam].name) there appears undefined item 0 array position out of (and produces error of course).

any ideas?


Popular posts from this blog