Created
August 30, 2019 23:23
-
-
Save mdarrik/d591bb4e6946efe02fc3f7760d2a2376 to your computer and use it in GitHub Desktop.
Shorten an Array To a Specified Length
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
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