mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
refactor(angular.copy): use slice(0) to clone arrays
slice(0) is way faster on most browsers
This commit is contained in:
parent
ec54712ff3
commit
28273b7f1e
1 changed files with 2 additions and 1 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue