var arr = [1,2,null,3,,4,5]; var sum = 0; for ( var keys in arr ){ if(!arr[keys]) continue; var xx = arr[keys]; s(xx); }; alert('Summa = ' + sum); function s(x){ return sum += x*x; };