『葉狂人』的怕失憶筆記 Front-End

亂數取 Array 內的任一值

筆記一下,怕忘記

亂數取 Array 內的任一值

var portList = ['6001', '6002', '6003', '6004', '6005', '6006', '6007', '6008'];
portList.getRandom = function () {
  return this[Math.floor(Math.random() * this.length)];
};
var port = portList.getRandom();

 

『葉狂人』的怕失憶筆記, author
「新發現的最大障礙不是無知,而是虛妄的知識。」
美國國會圖書館前館長 布爾斯汀