Enable Javascript array mutability in Script snap

It would be nice to manage Javascript arrays in Script snaps via the usual approaches. All of the scenarios below fail in Snaplogic.

Scenario 1
var fruit = [“banana”, “apple”];
fruit.push(“cherry”);

Scenario 2
var fruit = [“banana”, “apple”];
fruit[fruit.length] = “cherry”;

Scenario 3
var fruit = [“banana”, “apple”];
var newFruit = [“cherry”];
fruit = fruit.concat(newFruit);

Scenario 4
var fruit = [“banana”, “apple”];
fruit.splice(fruit.length, 0, “cherry”);

I currently work around this by taking the following steps:

  1. Create a Java ArrayList
  2. Use addAll to include the original Javascript array
  3. Use add to include the additional element
  4. Assign the ArrayList to the Javascript array reference

You should be able to parse this via python

Thanks Alan, it’s always helpful to have a variety of workarounds.

With that said, it would be good if Javascript based script snaps adhered to the specification. Imagine if there was some fundamental concept in Python that didn’t work in a script snap… it wouldn’t be a very nice solution to be forced to use Javascript! At any rate it’s a nasty surprise for anyone who expects this to work. There’s not even any meaningful error detail output when it occurs.