var zOrder = 0; // using naive iteration to speed things up a bit by avoiding function call overhead for(var x=0; x<this.cache.length; x++){ var i = this.cache[x]; zOrder += (i[0].z + i[1].z + i[2].z + i[3].z) / 4; } /* dojo.forEach(this.cache, function(item){ zOrder += (item[0].z + item[1].z + item[2].z + item[3].z) / 4; }); */ return (this.cache.length > 1) ? zOrder / this.cache.length : 0;