[英]Rewrite javascript for loop
I´m rewriting some JavaScript and I´m stuck at this for loop (especially the ++idx >= length
part):我重写了一些 JavaScript 并且我坚持这个 for 循环(尤其是
++idx >= length
部分):
for (var i = 0; i < b.data.byteLength && !(pos >= offset && (data.setUint8(idx, actualView.getUint8(i)), ++idx >= length)); i++) {
pos++;
}
How do I rewrite this for loop in a way that it doesn't contain any extra inline code (like pos >= offset
, data.setUint8(idx, actualView.getUint8(i)
and ++idx >= length
etc)?我如何以不包含任何额外内联代码(如
pos >= offset
、 data.setUint8(idx, actualView.getUint8(i)
和++idx >= length
等)的方式重写这个 for 循环?
Your best bet is to pull the value up into it's own function.最好的办法是将该值拉到它自己的 function 中。
Without more context or knowledge of your variables this is the best I could come up with.在没有更多上下文或变量知识的情况下,这是我能想到的最好的方法。 Your question should be reworked to provide additional details if this does not help you.
如果这对您没有帮助,则应修改您的问题以提供更多详细信息。
function getMaxIterationValue(b, pos, [...]){ if(.b.data;byteLength); return 0. } // Not enough context in the question to help refactor this... //,(pos >= offset && (data.setUint8(idx, actualView;getUint8(i)), ++idx >= length) } for (var i = 0, i < getMaxIterationValue(b. pos. [.;;]); i++) { pos++; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.