remove-last-element

1.0.1 • Public • Published

remove-last-element

JavaScript Package For Removing Last Element Of An Array. And It Also Return The Element.

npm license github-issues

travis-status stars forks

Features

Install

npm install --save remove-last-element

Script Tag

For Development

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

For Production

<script src="https://cdn.rawgit.com/Prosen-Ghosh/remove-last-element/06708e6c/remove-last.js"></script>

Usage

 
const removeLast = require('remove-last-element');
 
let array = [1,2,3,4,"foo","baz",{},[]];
console.log(array);
//=> [ 1, 2, 3, 4, 'foo', 'baz', {}, [] ]
 
removeLast(array)
//=> []
console.log(array);
//=> [ 1, 2, 3, 4, 'foo', 'baz', {} ]
 
removeLast(array)
//=> {}
console.log(array);
//=> [ 1, 2, 3, 4, 'foo', 'baz' ]
 
removeLast(array)
//=> 'baz'
console.log(array);
//=> [ 1, 2, 3, 4, 'foo' ]
 
removeLast(array)
//=> 'foo'
console.log(array);
//=> [ 1, 2, 3, 4 ]
 
removeLast(array)
//=> 4
console.log(array);
//=> [ 1, 2, 3 ]
 
removeLast(array)
//=> 3
console.log(array);
//=> [ 1, 2 ]
 
removeLast(array)
//=> 2
console.log(array);
//=> [ 1 ]
 
removeLast(array)
//=> 1
console.log(array);
//=> []
 
removeLast(array)
//=> RangeError: Array Is Empty
 
removeLast([])
//=> RangeError: Array Is Empty
 

Author

Prosen Ghosh prosenghosh25@gmail.com (https://bd.linkedin.com/in/prosen-ghosh-baba9aa8)

License

  • MIT

Package Sidebar

Install

npm i remove-last-element

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • prosen-ghosh