rolledback rolledback - 7 months ago 40
Javascript Question

Are JavaScript List Operations Synchronous?

So I've been doing some research into how JavaScript is actually single threaded even though it appears to be multithreaded (or at least that's how I understand it), and I was wondering if the following function would be guaranteed to complete before some other function is called.

I'm fairly certain that it is, but the call to

makes me worry that when it is called, some other function may execute first. That being said, I can't think of any sort of long running code that would be ran in

// adds a new node to children, after checking if its UID is not in childrenAdded
this.addChild = function(newChild) {
if (!_this._childrenAdded[newChild.uid]) {
_this._childrenAdded[newChild.uid] = true;


All Array methods, including push, are synchronous. That's pretty much the default for all operations in JS, asynchronous is the exception and documented in every such function.