简体   繁体   中英

Create empty array of length n

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

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

function makeArray() {
  var a = new Array(5);
  Logger.log(a);
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM