JavaScript30 - Day 4

By Camilla Krag Jensen naxoc |

Arrays

Mr. #javascript30, Wes says that he became a much better programmer when he forced himself to get really good at the array methods. I totally agree that this is central to be good at in most programming languages. Today he talked about these methods in particular:

These are all methods that exist in PHP too, so not many surprises for me there. Wes called them "a gateway drug for functional programming" and if you have dabbled a little with that it makes sense.

I saw this tweet explaining some of the methods and I couldn't help love it:

I didn't know about Array.from() that will make an iterable into an old fashioned array, so you can use that to make for instance a NodeList into an array so you can call map(), reduce(), or whatever array method on it. You can also make something into an array with the spread syntax like so:

const arr = [...cat.querySelectorAll('a')];

Logging arrays and objects

I had totally forgotten about console.table() — I should use that more. It formats like this: console.table()