Arrays

An array is an indexed collection.
Always zero based
Arrays only have one dimension
Array of Arrays
Arrays do not have fixed upper bounds


An array can contain anything

var mycollection = ['a',10,/a/,{ } ];  
mycollection[0]
mycollection.length /number of items and not the last index position


reducer function ?

var cellvalues = myRange.values.reduce(function (a,b) { return a.concat(b); } . [ ] ); 


var range = ctx.workbook.names.getItem("MyNamedRange").getRange(); 

range.values returns a 2D array
range.values.length // returns count of rows which is the first dimension
range.values[0].length // returns count of columns which the ?? Dimension



function add() { 
   var tempValue = 0;
   for (i=0; i < arguments.length; i++) {
      tempValue += arguments[i];
   }
   return tempValue;
}

var myValue = add(1,2,3,4);
alert(myValue);

Associative Arrays

This type of array lets you access the items in an array using a string lookup value.

var assArray = []; 
assArray["one"] = "myvalue";
assArray["two"] = "myvalue2";
alert(assArray["two"]);


© 2018 Better Solutions Limited. All Rights Reserved. © 2018 Better Solutions Limited TopNext