简体   繁体   English

比执行for循环更快的打印数组单元的方法

[英]Faster way to print an array cell than doing a for loop

So I have an array like: 所以我有一个像这样的数组:

var arra= new String [50,50];
// I add in arrays and for every added row, update count by 1. The columns are till incount which is less than 50.

for(i=0;i<=count;i++)
{
  for(j=0;j<incount;j++)
  {
    print (bigsub[i,j]);
  }
}

Is there a faster way I can do this? 有没有更快的方法可以做到这一点? Can I do this for the inner array as well? 我也可以对内部数组执行此操作吗?

您可以使用JSON.stringify(array) ,我认为它将起作用。

If all you need to do is print it (for debugging purposes) you can use @vimalnath's suggestion in the question comment above. 如果只需要打印(出于调试目的),则可以在上面的问题注释中使用@vimalnath的建议。 If however you want to do this for some heavy duty operations and you are open to using HTML 5 then you could employ multiple Web Workers to do this job asynchronously for you. 但是,如果您想对某些繁重的操作执行此操作,并且愿意使用HTML 5,则可以雇用多个Web Worker为您异步执行此工作。

要在javascript中打印数组,可以使用此

alert(arrayObj.join('\n'));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有比 for 循环更快的方法来对 javascript 中的图像进行阈值处理? - Is there a faster way than a for loop for thresholding an image in javascript? 有没有比 setTimeout(0) 更快地屈服于 Javascript 事件循环的方法? - Is there a faster way to yield to Javascript event loop than setTimeout(0)? 是否有更快的方式来更新json数组而不是循环它? - Is there a faster way to update a json array than by looping through it? 使用带有键数组的数字 for 循环是否比在 JavaScript 中使用 for-in 循环遍历 object 更快? - Is using a numeric for loop with an array of keys faster than iterating over an object with a for-in loop in JavaScript? Array.pop()在循环中的确比Array.length =快50倍 - Is Array.pop() in a loop really 50x faster than Array.length = 是否有比for循环更好的方法将对象数组的属性添加到另一个数组? - Is there a better way to add a property of an array of objects to another array than a for loop? 有没有比我这样做更有效的方法来排序标题数组(没有前导引号或文章)? - Is there a more efficient way of sorting an Array of titles than the way I'm doing it (without leading quotes or articles)? 为什么使用循环从数组的开始迭代到结束比从开始到结束和结束开始更快地迭代? - Why is using a loop to iterate from start of array to end faster than iterating both start to end and end to start? 为什么多个内联IF比每个数组项只有一个IF的循环快? - Why is multiple inline IFs faster than a loop with one IF per array entry JavaScript:为什么原生Array.prototype.map比Chrome控制台中的循环更快? - JavaScript: Why is native Array.prototype.map faster than for loop in Chrome console?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM