Visualising documentation: JavaSript array.of
Charlotte Fereday
Posted on September 20, 2020
Today’s function is array.of(), mdn description here.
This function creates an array from whatever it has been given. Sounds a lot like array.from() right?
The difference is array.of can take multiple parameters, so works especially well if there are many things to add to the array, i.e. numbers. Whilst array.from can only takes one parameter, so works well especially with a string to split each char into an element in the array.
Another difference between array.from is that if array.of is passed an array and a function it won't apply the function to each element in the array like array.from but instead stores the function in the array.
Would welcome any comments on good situations to use this function.
I've done my own version of the docs with sketches together. Here’s the folder for array.of. Check out the readme to see how you can run the examples.
Posted on September 20, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
August 17, 2023