getRandomArrayFromArray(array, size) { // 從一個數組中取出隨機幾個數
let resArr = []
size = size > array.length ? array.length : size
let tmpArr = [].concat(array) //拷貝原數組進行操作就不會破壞原數組
for (let i = 0; i < size; i++) {
let n = Math.floor(Math.random() * tmpArr.length) // floor小於等於x的最大整數
resArr.push(tmpArr[n])
tmpArr.splice(n, 1) // 在臨時數組中刪掉,避免重復獲取
}
return resArr
},
