remove-last-element
v1.0.1
Published
JavaScript Package For Removing Last Element Of An Array. And It Also Return The Element.
Downloads
1
Maintainers
Readme
remove-last-element
JavaScript Package For Removing Last Element Of An Array. And It Also Return The Element.
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 [email protected] (https://bd.linkedin.com/in/prosen-ghosh-baba9aa8)
License
- MIT