I have been using the
destructuring assignment syntax in Google Apps Script for some time. It simplifies code like this quite a bit:
var [needle, haystack, startAt] = validateArguments_({ args: arguments, minNumArgs: 2 });
The
spread syntax, the
...obj spread operator and
rest parameters would obviously be very useful as well, but I have been unable to get them to work. This is a bit confusing, since Google's own sample code does use the spread operator, for example in the Date Add and Subtract add-on
sample code:
if (max == 0) {
return func(...args);
}
Google originally used func.apply(null, args) in the 15 December 2017 commit of the code, but switched to func(...args) in the 20 June 2018 commit.
Is this a V8 only thing, or is there a way to use the spread syntax and rest parameters in regular Rhino Google Apps Script?
Or did someone at Google just blindly "fix" a lint warning in the Date Add and Subtract add-on and commit
sample code that does not actually work in Google Apps Script?
Cheers --Hyde