Lodash 'includes' not working'

I tried to use this function, but it is not defined ( jsfiddle ).

console.log(_.include([1, 2, 3], 1)); console.log(_.includes([1, 2, 3], 1)); 

I also saw that 'include;' without 's' work well. are they mistaken in docs ? or am I missing something? thanks!

+5
source share
2 answers

You look at the documents for v.3.3.1, including v.1.2.1 in your script.

_.include was renamed _.contains , and it was later renamed _.includes .
Starting with version v.2.4.1, renaming to _.includes has not yet occurred.

So use the updated version of lodash and everything will be fine:

 console.log(_.include([1, 2, 3], 1)); console.log(_.includes([1, 2, 3], 1)); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.4.0/lodash.js"></script> 
+8
source

I experienced this in lodash-core 4.17.4. The solution was to use the full assembly instead of the main assembly.

+1
source

Source: https://habr.com/ru/post/1214823/


All Articles