How to use the initial function from underscore

Find comprehensive JavaScript underscore.initial code examples handpicked from public code repositorys.

5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
// values in the array. Aliased as `head` and `take`. The **guard** check
// allows it to work with `_.map`.
_.first = _.head = _.take = function(array, n, guard) {
  if (array == null) return void 0;
  if (n == null || guard) return array[0];
  return _.initial(array, array.length - n);
};

// Returns everything but the last entry of the array. Especially useful on
// the arguments object. Passing **n** will return all the values in
fork icon0
star icon2
watch icon0