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



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 next 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?

javascript google-chrome internet-explorer firefox runtime-error

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -