Created
April 21, 2016 15:06
-
-
Save rjmacarthy/e426125e5f91fc5d7864eff03d632047 to your computer and use it in GitHub Desktop.
Get a chunk of array from the end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [ -3, 1, 2, -2, 5, 6 ] | |
var chunkAmount = 3; | |
var chunk = arr.splice(arr.length-chunkAmount,arr.length); | |
console.log(chunk) // [-2, 5, 6 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment