Create ArrayBuffer from Array (holding integers) and back again

前端 未结 2 1201
名媛妹妹
名媛妹妹 2020-12-31 02:25

It seems so simple, but I cannot find out how to convert an Array filled with integers to an ArrayBuffer and back again to an Array. T

2条回答
  •  盖世英雄少女心
    2020-12-31 03:11

    You can't use an ArrayBuffer directly, but you can create a typed array from a normal array by using the from method:

    let typedArray = Int32Array.from([-2, -1, 0, 1, 2])
    

提交回复
热议问题