当前位置:网站首页>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));
边栏推荐
- Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
- What problems should be evaluated before implementing MES management system
- 要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
- [Yocto RM] 2 - Yocto Project Terms
- 将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
- Capacitor
- The research group of Xuyong and duanwenhui of Tsinghua University has developed an efficient and accurate first principles electronic structure deep learning method and program
- 766. toplitz matrix
- 评价——灰色关联分析
- OS模块与OS.path 模块的学习
猜你喜欢
数据库查询优化:主从读写分离及常见问题
Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
[Niuke discussion area] Chapter 4: redis
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
Qu'est - ce que la numérisation? Qu'est - ce que la transformation numérique? Pourquoi les entreprises choisissent - elles la transformation numérique?
pytorch_ lightning. utilities. exceptions. MisconfigurationException: You requested GPUs: [1] But...
mysql面试百题集
Overview of drug discovery-01 overview of drug discovery
Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
如何理解 Transformer 中的 Query、Key 与 Value
随机推荐
Arrays. Aslist() pit
什麼是數字化?什麼是數字化轉型?為什麼企業選擇數字化轉型?
Deep parsing of kubernetes controller runtime
Prometeus 2.35.0 new features
Supervised, unsupervised and semi supervised learning
TI AM3352/54/59 工业核心板硬件说明书
Review of drug discovery-03-molecular design and optimization
Appium自动化测试基础— 补充:App的包名(appPackage)和启动名(appActivity)
树莓派实现温控风扇智能降温
面试官问:JS的this指向
Cesium 点击绘制多边形(动态绘制多边形)
9. Openfeign service interface call
Four classic training modes in comparative learning
Capacitor
Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
centos8-操作记录-命令版-yum-redis-mysql-nacos-jdk
Review of drug discovery-02-prediction of molecular properties
Intranet penetration with FRP
Ten thousand words long article understanding business intelligence (BI) | recommended collection
如何理解 Transformer 中的 Query、Key 与 Value