Introduction:
[arrays]
are a list of variables. They are stored in square brackets,
but can be created using new Array()
round brackets.
myArray = ["one", "two", 3, 4, true, "true", false, "false"];
let myNewArray = new Array(1, 2, "three", "four");
- Declare (create) an array
- Create an array from a string
- Transform an array into a string
- Retrieving Information
let x = [];
Empty [array]
let y = ["No", "longer", "empty"];
Filled [array]
myArray[3];
myNewArray[3];
Get value at position #3
myArray.indexOf(item, (start));
Get index of [array]
value
myArray.valueOf();
Get values of [array]
typeof(myArray[#]);
Get data types of values in [array]
Array.isArray(myArray);
Determines if [array]
or not. Returns boolean
myArray.entries();
Iterate through [array]
and return key/value
myArray.forEach(item, index);
Iterate through [array]
and return key/value
myArray.keys();
Iterate through [array]
and return keys
myArray.constructor;
Returns constructor function for an object
, thus tells whether
something is a Number, a "string"
or an [array]
myArray.length;
Returns the number of elements
in an [array]
myArray.indexOf(item, (start));
Returns the index of elements
in an [array]
myArray.lastIndexOf(item, (start));
Returns the last index of elements
in an [array]
myArray.includes(item, (start));
Checks if an [array]
contains a specific value. Returns a boolean