Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
401 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /**
|
---|
| 2 | * Gets the last element of `array`.
|
---|
| 3 | *
|
---|
| 4 | * @static
|
---|
| 5 | * @memberOf _
|
---|
| 6 | * @since 0.1.0
|
---|
| 7 | * @category Array
|
---|
| 8 | * @param {Array} array The array to query.
|
---|
| 9 | * @returns {*} Returns the last element of `array`.
|
---|
| 10 | * @example
|
---|
| 11 | *
|
---|
| 12 | * _.last([1, 2, 3]);
|
---|
| 13 | * // => 3
|
---|
| 14 | */
|
---|
| 15 | function last(array) {
|
---|
| 16 | var length = array == null ? 0 : array.length;
|
---|
| 17 | return length ? array[length - 1] : undefined;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | module.exports = last;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.