Skip to content

Commit 28273b7

Browse files
committed
refactor(angular.copy): use slice(0) to clone arrays
slice(0) is way faster on most browsers
1 parent ec54712 commit 28273b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Angular.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ function copy(source, destination){
556556
destination = source;
557557
if (source) {
558558
if (isArray(source)) {
559-
destination = copy(source, []);
559+
// http://jsperf.com/copy-array-with-slice-vs-for
560+
destination = source.slice(0);
560561
} else if (isDate(source)) {
561562
destination = new Date(source.getTime());
562563
} else if (isObject(source)) {

0 commit comments

Comments
 (0)