mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-15 12:09:02 +08:00
refactor(angular.copy): use slice(0) to clone arrays
slice(0) is way faster on most browsers
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user