last-element
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/last-element package

1.0.1 • Public • Published

last-element

Get the last element in an array.

npm license github-issues

nodei.co

travis-status stars forks

Features

npm Install

npm install --save last-element

Script Tag

For Development

<script src="https://rawgit.com/Prosen-Ghosh/last-element/master/last.js"></script>

For Production

<script src="https://cdn.rawgit.com/Prosen-Ghosh/last-element/5c22c2c2/last.js"></script>

Usage

const last = require('last-element');
 
last([]);
//=> []
 
last([1]);
//=> 1
 
last([1,5,6,""]);
//=> ''
 
last([1,5,6,"",{}]);
//=> {}
 
last([1,5,6,"",{},[]]);
//=> []
 
last([1,5,6,"",{},[],-5]);
//=> -5
 
last(); // without parameter this function will throw a type error
//=> TypeError: last() expects an array parameter
 

Author

Prosen Ghosh prosenghosh25@gmail.com

License

  • MIT

Install

DownloadsWeekly Downloads

11

Version

1.0.1

License

MIT

Last publish

Collaborators

  • prosen-ghosh