admin管理员组文章数量:1345176
I think this may be a naive question. I often find that I've got multiple xhr requests waiting on returns. I keep track of the requests I've issued in a JavaScript array. that is, when a new request is made, I add it to the array, then when the thread pletes I remove it from the array.
In a multi-threaded OS, I'd be worried about threads crossing but I know JavaScript is single threaded. Should I worry about the array being consistent?
Sorry if this has been asked and and answered. I looked and did not find a link around array safe push.
I think this may be a naive question. I often find that I've got multiple xhr requests waiting on returns. I keep track of the requests I've issued in a JavaScript array. that is, when a new request is made, I add it to the array, then when the thread pletes I remove it from the array.
In a multi-threaded OS, I'd be worried about threads crossing but I know JavaScript is single threaded. Should I worry about the array being consistent?
Sorry if this has been asked and and answered. I looked and did not find a link around array safe push.
Share Improve this question edited Feb 9, 2023 at 20:12 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 28, 2012 at 16:00 Peter KellnerPeter Kellner 15.5k28 gold badges114 silver badges204 bronze badges1 Answer
Reset to default 12No, you should not worry about it. JavaScript is single-threaded, like you said.
本文标签: javascriptPush to array safelyhow to Worry or notStack Overflow
版权声明:本文标题:javascript - Push to array safely, how to? Worry or not? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743794768a2540224.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论