A quick list-style reference to JS arrays and loops.
Note: For associative arrays use "Object" in stead of "Array"
var my_rray = [];
var my_rray = new Array(); (keyword "new" is optional)
var my_rray = ["foo", "bar"];
var my_rray = new Array("foo", "bar"); (keyword "new" is optional)
var my_rray = new Array(); (keyword "new" is optional)
var my_rray = my_string.split(",");
var my_rray = my_string.match("RegExp");
var my_rray = array1.concat(array2 [, ...]);
var my_rray = array1.slice(start [, end]);
var isThisAnArray = Array.isArray(my_rray); ("Array." optional)
var howManyElements = my_rray.length;
var firstElement = my_rray[0];
var lastElement = my_rray[my_rray.length - 1];
var x = my_rray.indexOf("foo" [, start]);
var x = my_rray.findIndex(function("foo" [, index [, array]]) [, thisValue]);
(link)
var x = my_rray.lastIndexOf("foo" [, start]);
var x = my_rray.join(",");
var x = my_rray.toString();
var x = my_rray.valueOf();
my_rray.copyWithin(target, start [, end]);
(link)
my_rray.fill(value [, start [, end]]);
my_rray.reverse();
my_rray.sort([function(){}]);
(link)
my_rray.push("foo" [, ...]);
my_rray['index'] = "foo"; ('index' must be a number)
my_rray += "foo";
var x = my_rray.unshift("foo" [, ...]);
var x = my_rray.push("foo" [, ...]);
var x = my_rray.shift();
var x = my_rray.pop();
var x = my_rray.splice(index , number [, item1 [, ...]]);
(link)
Note: these all use callback functions.
my_rray.every(function("foo" [, index [, array]]) [, thisValue]);
my_rray.forEach(function("foo" [, index [, array]]) [, thisValue]);
my_rray.filter(function("foo" [, index [, array]]) [, thisValue]);
my_rray.find(function("foo" [, index [, array]]) [, thisValue]);
my_rray.map(function("foo" [, index [, array]]) [, thisValue]);
my_rray.reduce(function(total, currentValue [, currentIndex [, array]]) [, initialValue]);
my_rray.reduceRight(function(total, currentValue [, currentIndex [, array]]) [, initialValue]);
switch(expression) { case x: // code here... break; case y: // code here... break; default: // code here... }
for (let i = 0; i < object.length; i++) { // code here... }
for (i in object) { // code here... }
for (let i of iterable) { // code here... }
for await (let i of iterable) { // code here... }
while (condition) { // code here... }
do { // code here... } while (condition)
if (condition) { // code here... } else if { // code here... } else { // code here... }
try { // code here... } catch (exception_var) { // code here... } finally { // code here... }