简体   繁体   中英

push to array safely, how to? worry or not?

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 completes 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.

No, you should not worry about it. JavaScript is single-threaded, like you said.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM