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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    10
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    10
  • 1.0.0
    2

Package Sidebar

Install

npm i last-element

Weekly Downloads

12

Version

1.0.1

License

MIT

Last publish

Collaborators

  • prosen-ghosh