last-element
v1.0.1
Published
Get the last element in an array.
Downloads
39
Readme
last-element
Get the last element in an array.
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 [email protected]
License
- MIT