Arrays

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


An array is a collection of elements that use the same name but are distinguished by an index value.
The individual items within an array are called elements.
The numerical value used to access the individual elements is called the index.
The elements can be stored at non-continuous locations in the array
Arrays are untyped collections.
The elements in an array can have any data type

var myArray = [ 
   "some text",
   "numbers",
   "objects",
   200,
   false
];

Default Values





An array can contain anything

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

var myArr = new Array() // ?? 

myArr.indexOf 
myArr.lastIndexOf

reducer function ?

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


var range = context.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"]);

Adding Properties

It is possible to add properties to an array

myArray2.myproperty = "Text"; 



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