I have a function that requires one parameter and a dynamic set of additional parameters. I am passing an array of blobs to the function. Below is a simplified version of the function:
function test(directory, blob0, blob1) {
for (var argumentIndex = 1; argumentIndex < arguments.length; argumentIndex++) {
var bytes = arguments[argumentIndex].getBytes();
//perform some operations
}
}
Since I am using the rhino runtime, I cannot take advantage of the spread operator. The closest solution I have found is to use the apply function, but I am unsure how to include the required parameter (directory) along with the blob parameters in the test function above.
var blobs = [];
blobs[0] = getBlob();
blobs[1] = getBlob();
blobs[2] = getBlob();
test.apply(null,blobs) //required parameter (directory) is not being set