I understand that functions in JavaScript can take any number of arguments.
- Yup. It's weird, but super flexible. I like the idea of being able to omit arguments that I don't need.
I can describe the similarity between blocks in Ruby and anonymous functions in JavaScript.
- Blocks in ruby and anonymous functions in JS both can arguments of some type (often a collection) and will run some code related to those arguments. In JS we can pass arguments into an anonmyous function and do something with them inside of that to return some value, which is very similar to ruby. In the same way that we can pass a block to
.each
in ruby, we can pass an anonymous function to .forEach
in JS.
Where are the methods available to all arrays (e.g. forEach
, map
, etc.) defined?