Skip to content

Instantly share code, notes, and snippets.

@mdarrik
Created August 30, 2019 23:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdarrik/d591bb4e6946efe02fc3f7760d2a2376 to your computer and use it in GitHub Desktop.
Save mdarrik/d591bb4e6946efe02fc3f7760d2a2376 to your computer and use it in GitHub Desktop.
Shorten an Array To a Specified Length
const arrayToShorten = [0,1,2,3,4,5,6,7]
arrayToShorten
// output: [ 0, 1, 2, 3, 4, 5, 6, 7 ]
arrayToShorten.length = 3
arrayToShorten
// output: [ 0, 1, 2 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment