Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lodash, Uncaught TypeError: _.remove is not a function

I am including lodash v.4.17.11 js file in my HTML web page using HTML script tag.

<body>
...
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.min.js"></script> 
</body>

Some functions like _.filter() or _.reduce() are working fine, but _.remove() gave me:

Uncaught TypeError: _.remove is not a function

It seems that this function does not exist in the library file! although it is listed in the documentation.

How should I do to solve this? Thank you!

https://lodash.com/docs/4.17.11#remove

like image 262
Ahmed Ismail Avatar asked Sep 17 '25 16:09

Ahmed Ismail


1 Answers

You are using the core lib. It seems you need more than the core:

instead of: https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.min.js

use: https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js

Here are more details on the differences:

https://github.com/lodash/lodash/wiki/Build-Differences

For your convenience:

4 kB (gzipped) core build (63 methods; Backbone ≥ v1.3.0 compatible)

_.assignIn, _.before, _.bind, _.chain, _.clone, _.compact, _.concat, _.create, _.defaults, _.defer, _.delay, _.each, _.escape, _.every, _.filter, _.find, _.flatten, _.flattenDeep, _.forEach, _.has, _.head, _.identity, _.indexOf, _.isArguments, _.isArray, _.isBoolean, _.isDate, _.isEmpty, _.isEqual, _.isFinite, _.isFunction, _.isNaN, _.isNull, _.isNumber, _.isObject, _.isRegExp, _.isString, _.isUndefined, _.iteratee, _.keys, _.last, _.map, _.matches, _.max, _.min, _.mixin, _.negate, _.noConflict, _.noop, _.once, _.pick, _.reduce, _.result, _.size, _.slice, _.some, _.sortBy, _.tap, _.thru, _.toArray, _.uniqueId, _#value, & _.values

Limitations:

  • No _.matchesProperty iteratee shorthand
  • No deep property path support
  • No lazy evaluation
  • No placeholder support
  • No robust cloning (arrays & plain objects only)
  • No support for maps, sets, & typed arrays
like image 107
Akrion Avatar answered Sep 19 '25 08:09

Akrion