While the idea of a function array inside an array doesn’t really make any sense, it works.
Join function allows you to create a new array that contains only those elements that share a unique identifier. For example, say we have a website with categories and we’d like to have every article with a category in it. We could create an array with an array of unique categories and then loop through them and find all articles with the category we’d like to have as well.
A lot of people say that this is a better way than a function array. But I don’t think it works for us. I think it’s a lot more efficient than a function array.
This is still true but it is much more efficient. That is because arrays are generally slower than functions. To see why this is true, take another array. Say that we have an array of pages that we would like to find the category wed like to have on this website. We can do this in a single pass using the join() function. We would first select all the pages that have wed as a category. Then we would check if any of the pages have wed as a category.
This is a great optimization, but it is not a great optimization if our array is large. The join function works with arrays that are up to about 200 elements long. In our example, if we wanted to only get the wed pages we could write a single function that would loop through the page array, create a new array of wed pages, and then put those wed pages back into the page array.
In our case, we wanted to get all of the wed pages and put them back into the page array. The join is the function that would do that. In fact, join would be a good function to get only wed pages.
The join function is a function that would work in any version of the DOM. It’s really just a wrapper for document.getElementsByTagName().