Skip to content

Instantly share code, notes, and snippets.

@stefanfrede
Created January 30, 2016 08:47
Show Gist options
  • Save stefanfrede/822ac5d32b32cd139a11 to your computer and use it in GitHub Desktop.
Save stefanfrede/822ac5d32b32cd139a11 to your computer and use it in GitHub Desktop.
The most performant way to empty an array.
/**
* 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