[ ]
designates an Array
.length
will return the number of items inside an arrayarrayName[#]
0
arrayName[#][#]
indexOf()
-1
if the item is not in the arrayconst birds = ['Parrot', 'Falcon', 'Owl'];
console.log(birds.indexOf('Owl')); // 2
console.log(birds.indexOf('Rabbit')); // -1
.push()
.unshift()
.pop()
.shift()
.splice()
const cities = ['Manchester', 'Liverpool', 'Edinburgh', 'Carlisle'];
const index = cities.indexOf('Liverpool');
if (index !== -1) {
cities.splice(index, 2);
}
console.log(cities); // [ "Manchester", "Carlisle" ]
of
for
const pets = ['cat', 'dog','bird'];
for (const pet of pets) {
console.log(pet);
}; // >>Will list out each item in pets
map()
strings
and arrays
.split()
.join()
.toString()
,
as the delimiterName | Shorthand operator | Meaning | |
---|---|---|---|
Assignment | x = f() | x = f() | |
Addition assignment | x += f() | x = x + f() | |
Subtraction assignment | x -= f() | x = x - f() | |
Multiplication assignment | x *= f() | x = x * f() | |
Division assignment | x /= f() | x = x / f() | |
Remainder assignment | x %= f() | x = x % f() | |
Exponentiation assignment | x **= f() | x = x ** f() | |
Left shift assignment | x «= f() | x = x « f() | |
Right shift assignment | x »= f() | x = x » f() | |
Unsigned right shift assignment | x »>= f() | x = x »> f() | |
Bitwise AND assignment | x &= f() | x = x & f() | |
Bitwise XOR assignment | x ^= f() | x = x ^ f() | |
Bitwise OR assignment | x |= f() | x = x | f() | |
Logical AND assignment | x &&= f() | x && (x = f() | ) |
Logical OR assignment | x ||= f() | x || (x = f()) | |
Logical nullish assignment | x ??= f() | x ?? (x = f()) |