Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 535
Chris Barrett Avatar asked Apr 08 '26 19:04

Chris Barrett


1 Answers

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

function makeArray() {
  var a = new Array(5);
  Logger.log(a);
};
like image 102
ADW Avatar answered Apr 10 '26 08:04

ADW