No Description

last.js 399B

12345678910111213
  1. define(['./rest'], function (rest) {
  2. // Get the last element of an array. Passing **n** will return the last N
  3. // values in the array.
  4. function last(array, n, guard) {
  5. if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
  6. if (n == null || guard) return array[array.length - 1];
  7. return rest(array, Math.max(0, array.length - n));
  8. }
  9. return last;
  10. });