Using Array.prototype.slice() to clone an array
authorAlexander Ebert <ebert@woltlab.com>
Sun, 24 May 2015 13:59:46 +0000 (15:59 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 24 May 2015 13:59:46 +0000 (15:59 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Core.js

index 811a7189e8a05810263b9eccb6216af5d7a9417b..f64496a86540e246582f8e1e8a0d8da7aadae145 100644 (file)
@@ -18,14 +18,7 @@ define([], function() {
        };
        
        var _cloneArray = function(oldArray) {
-               var i = oldArray.length;
-               var newArray = new Array(i);
-               
-               while (i--) {
-                       newArray[i] = oldArray[i];
-               }
-               
-               return newArray;
+               return oldArray.slice();
        };
        
        var _cloneObject = function(obj) {