javascript - Lodash: Array without last element, no mutation -


i'm looking way retrieve array without last element, , without being mutated.

  • _.remove mutate array , searches value not index (even if asked there)
  • _.without searches value, not index

i have _.filter(array, function(el, i) { return != array.length -1}); siouf, not explicit , needs array stored somewhere.

thanks

i looking "butlast", found initial, job:

var xs = [1, 2, 3, 4];  var xs2 = _.initial(xs);  console.log(xs, xs2);  // [1, 2, 3, 4] [1, 2, 3] 

Comments

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -