array javascript

JavaScript
add array javascript
var cars = [

  "Saab",

    "Volvo",

    "BMW"

]; var cars = ["Saab", "Volvo", "BMW"];
 var myArray = [ "Jack", "Sawyer", "John", "Desmond" ];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));var fruits = ['Apple', 'Banana'];

console.log(fruits.length);
// 2
Source

Also in JavaScript: