arrays javascript

JavaScript
var cars = ["Saab", "Volvo", "BMW"];
 //single array declaration
var car1 = "Saab";
var car2 = "Volvo";
var car3 = "BMW";

//one line
var cars = ["Toyota", "Jeep", "BMW"];

//multiple lines
var cars = [
 "Toyota",
 "Jeep",
 "BMW"
];//create array
var things = ["banana", "car", "computer"];
//access array(starts at 0)
things[0]
//iterate through an array
for (var i = 0; i < things.length; i++) {
  things[i]
}The JavaScript filter() method has several components to its syntax.

newArray = initialArr.filter(callback);
newArray: you name the array that will consist of the filtered elements.
initialArr: the name of the original array.
callback: the method applied to the initialArr.
The callback can have three arguments as well:

element: the current element of the array.
index: the index number of the currently handled value.
array: the original array.
Therefore, the full syntax of the JavaScript array filter function would look like this:

newArray = initialArr.filter(callback(element, index, array));[element0, element1, ..., elementN]

new Array(element0, element1[, ...[, elementN]])
new Array(arrayLength)//create an array like so:
var colors = ["red","blue","green"];

//you can loop through an array like this:
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}
Source

Also in JavaScript: