Difference between revisions of "Arrays"

From CodeStuff
Jump to: navigation, search
(Created page with "Arrays are a good way to handle lists of things. In JavaScript, Arrays use the square brackets [ and ] To create an Array, all you need to do is assign the list to a variab...")
 
Line 43: Line 43:
  
  
The mozilla foundation has documentation on Javascript Arrays at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
+
The Mozilla foundation has documentation on JavaScript Arrays at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
  
 
In additon to the standard features of Arrays available to JaveaScript users,  Code on this wiki has been sweetened with SugarJS  
 
In additon to the standard features of Arrays available to JaveaScript users,  Code on this wiki has been sweetened with SugarJS  

Revision as of 09:44, 10 December 2015

Arrays are a good way to handle lists of things. In JavaScript, Arrays use the square brackets [ and ]

To create an Array, all you need to do is assign the list to a variable

   var m = [3,6,8];

To access individual items of the list you use the square brackets again.

   var p = m[1]; 

Entries in the list start counting from zero so m[0] is the first item in the list. [2] accesses the item at position 2 but it is important to remember that position 2 is the third item in the list. If you are new to programming, this might seem a bit odd at first. don't worry, it doesn't take too long to adjust to counting from zero.


You can also add items to lists. The push function is available to add items to the


The Mozilla foundation has documentation on JavaScript Arrays at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

In additon to the standard features of Arrays available to JaveaScript users, Code on this wiki has been sweetened with SugarJS The additional features are documented at http://sugarjs.com/api/Array

SugarJS allows some cool abilities like exclude