Remember how to spell lentgh lenght length. It is very good when working with arrays in javascript.
You could also create a small helper function like this:
function size(arr) {
return array.length;
}
Size is much easier to spell than length. This will also work for strings.
Would like to know the size of an object? You could use our nice function to do this:
const obj = {
keyA: "A",
keyB: "B",
};
size(Object.keys(obj)); // 2
That is sweet.
Hope you find this useful or funny. Until next time.