refactor(angular.copy): use slice(0) to clone arrays

slice(0) is way faster on most browsers
This commit is contained in:
Igor Minar 2013-02-04 08:56:51 -08:00
parent ec54712ff3
commit 28273b7f1e

View file

@ -556,7 +556,8 @@ function copy(source, destination){
destination = source;
if (source) {
if (isArray(source)) {
destination = copy(source, []);
// http://jsperf.com/copy-array-with-slice-vs-for
destination = source.slice(0);
} else if (isDate(source)) {
destination = new Date(source.getTime());
} else if (isObject(source)) {