Lodash core vs full how to#
I assume that you have some basic working knowledge of javaScript in general, and how to get started with using lodash in a project. There is also the ncat method in javaScript itself that works the same way. This is a post on the lodash method _.concat that can be used to combine, or concatenate two or more arrays into one array. 1 - lodash concat, and What to know first
Lodash core vs full code#
Also although there might not be much of a point using _.concat by itself in light of the vanilla js ncat, diving deep into the source code _.concat uses some internal methods that are shared with related methods like _.flattenDeep.
![lodash core vs full lodash core vs full](https://www.techspot.com/articles-info/1492/images/F-2.jpg)
Still it is there just for the hell of it, and looking into the lodash source code, it looks like the lodash developers are not just directly referencing the native method, as is the case with some of these methods.Īlthough this is a lodash post on _.concat, this is also a kind of post of concatenating arrays in general. These are methods where a native javaScript method is just simply being wrapped, and in this case more os less just for the sake of consistency when it comes to using lodash. The lodash concat method is one of several methods in lodash that I have come to call lodash wrapper methods. If you are wondering what the difference is between the lodash and native options when it comes to an array concatenation method in javaScript, the answer is there is none beyond that os just making an abstraction. So then while I am at it maybe I should touch base on various other methods in lodash as well as native javaScript that have to do with creating a product from one or more arrays also. There is of course more than one intention when it comes to the subject of adding two arrays together though, in some cases i might not want to concatenate elements from two arrays, into a single array, but create some kind of single primitive value that is a sum from two or more arrays.
![lodash core vs full lodash core vs full](https://www.techspot.com/articles-info/1968/images/2020-01-08-image-4.jpg)
![lodash core vs full lodash core vs full](https://www.notebookcheck.net/fileadmin/_processed_/csm_7th_Gen_Launch_Pre_Briefing_Presentation_Under_Embargo_until_June_1_Lega..._page_012_efbfb7b17a.jpg)
Regardless of which one you use the result is the same, adding two or more arrays into a single array in other words concatenation of arrays rather then Strings. In this lodash post I will be writing about the lodash _.concat method, and of course the corresponding vanilla js method ncat built into the Array prototype in core javaScript itself.