How to copy TypedArray into another TypedArray?

前端 未结 3 1213
无人共我
无人共我 2021-01-17 10:15

C# has a high performance array copying function to copy arrays in place:

Array.Copy(source, destination, length)

It\'s faster tha

3条回答
  •  有刺的猬
    2021-01-17 10:52

    You can clone an array using slice(0);.

    var clone = myArray.slice(0);
    

    And you can make it a native method:

    Array.prototype.clone = function() {
        return this.slice(0);
    };
    

    Performance link comparing to loop

提交回复
热议问题