当前位置:网站首页>JS array random value (random array value)
JS array random value (random array value)
2022-06-28 02:10:00 【The most ferocious little seal】
principle : Get by random numbers [0, The length of the array ] Key value of , Then directly get the array value corresponding to the key .
Be careful : The following code applies to one-dimensional arrays , Multidimensional arrays extend themselves !
function randomArr(arr){
return arr[parseInt(Math.random() * arr.length, 10)]
}
var color_arr = ['#00ff089e', '#0043ff9e', '#fff7009e', '#ff00009e'];
console.log(' Random color values :', randomArr(color_arr));
边栏推荐
- Jenkins - 邮件通知 Email Notification 插件
- Class initialization and callback usage
- 机器学习笔记 - 时间序列作为特征
- Réseau neuronal pour la solution détaillée Multi - diagrammes de fondation zéro
- Cesium 抗锯齿(线,边框等)
- Coscon'22 lecturer solicitation order
- pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [1] But...
- Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
- 学习 pickle
- Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
猜你喜欢

Solve storage problems? WMS warehouse management system solution

Numpy----np.tile()函数解析

Jenkins - 邮件通知 Email Notification 插件

Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released

Drug interaction prediction based on learning size adaptive molecular substructure

声网 VQA:将实时互动中未知的视频画质用户主观体验变可知

将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)

Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)

如何理解 Transformer 中的 Query、Key 与 Value

零基础多图详解图神经网络
随机推荐
205. 同构字符串
[sylixos] I2C device driver creation and use
Interviewer asked: Inheritance of JS
Jenkins - Groovy Postbuild 插件丰富 Build History 信息
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
Ten thousand words long article understanding business intelligence (BI) | recommended collection
面试官问:能否模拟实现JS的new操作符
Numpy----np.meshgrid()
数据库的新选择 Amazon Aurora
[elt.zip] openharmony paper Club - memory compression for data intensive applications
如何高效读书学习
如何阅读一篇论文
Supervised, unsupervised and semi supervised learning
Is it safe to open an online futures account?
Numpy----np.reshape()
MapReduce elementary programming practice
Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)
Implementation of timed tasks in laravel framework
[Yocto RM]1 - System Requirements
评价——秩和比综合评价