If the goal is to end the loop when ii reaches 1010 or ii reaches the end of the array, you may write it like this :
for (var i=0; i<x.length && i<10; i++) { In that case you might also compose it like this
for (var i=0; i<Math.min(x.length,10); i++) { or for better performances :
for (var i=0, n=Math.min(x.length,10); i<n; i++) {