Created
January 30, 2016 08:47
-
-
Save stefanfrede/822ac5d32b32cd139a11 to your computer and use it in GitHub Desktop.
The most performant way to empty an array.
This file contains 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
/** | |
* Example: | |
* var foo = [ 1,2,3 ]; | |
* emptyArray( foo ); | |
* console.log( foo ); | |
* // [] | |
*/ | |
function emptyArray( arr ) { | |
//empty the array | |
arr.length = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment