Skip to content

Commit

Permalink
refactor(angular.copy): use slice(0) to clone arrays
Browse files Browse the repository at this point in the history
slice(0) is way faster on most browsers
  • Loading branch information
IgorMinar committed Feb 11, 2013
1 parent ec54712 commit 28273b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 28273b7

Please sign in to comment.