can we do this at some point?

 From:  Michael Gibson
9747.10 In reply to 9747.8 
Hi Brian, yes that code will both clear out the factories array while also calling .cancel() on each factory. There's a separate factory for each selected surface and when a UI control has changed that is clearing out any previously displayed result before making new ones.

The JavaScript array object has a .pop() method on it which removes the last element in the array but also passes it back as the return value from pop() so it can be used in this way. This type of construct is called "function chaining" or "method chaining": https://en.wikipedia.org/wiki/Method_chaining .

Another way to write it would be:

while ( factories.length != 0 )
{
    var factory = factories.pop();
    factory.cancel();
}

or something like:

for ( var i = 0; i < factories.length; ++i )
{
    var factory = factories[i];
    factory.cancel();
}

factory.length = 0;


All of those would do the same thing, the pop method with chaining is just kind of nice since it's so compact.

- Michael