3

Pretty basic question but does anyone know how to create an empty array in Google Apps Script with a defined integer length n. Tried new array(n) but don't think its part of the Google Apps Script spec.

I know I can do it with with a loop (or manually typing it out) but wondered if there is a more elegant solution

1 Answer 1

10

Did you try new Array(n) with a capital A?

function makeArray() {
  var a = new Array(5);
  Logger.log(a);
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.