Google Apps Script doesn't appear to recognize the function Object.assign()
. When trying to use it I get the error:
TypeError: Cannot find function assign in object function Object() { [native code for Object.Object, arity=1] }
The code I'm testing the function with is the example copied directly from MDN:
function myFunction() {
const object1 = {
a: 1,
b: 2,
c: 3
};
const object2 = Object.assign({c: 4, d: 5}, object1); //error is thrown here
console.log(object2.c, object2.d);
// expected output: 3 5
}
I copy-pasted the above code directly into the Chrome developer console, which ran fine and gave the expected output.
I can't find anything online saying that this particular function is not supported by apps script, or anything like that. So, what's going on? How can I fix this?