Created
December 18, 2014 17:03
-
-
Save malexandre/6061ef7cea98462f8709 to your computer and use it in GitHub Desktop.
Copy an array into another that already exists (like 'dest = src;', except that it keeps the reference to the existing 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
function copyArray(src, dest) | |
{ | |
// (performance: http://jsperf.com/empty-javascript-array & http://jsperf.com/array-extending-push-vs-concat) | |
while(dest.length > 0) | |
{ | |
dest.pop(); | |
} | |
if (src) | |
{ | |
for (var i = 0; i < src.length; ++i) | |
{ | |
dest.push(data.Search[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment