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

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -