当前位置:网站首页>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));
边栏推荐
- 1382. 将二叉搜索树变平衡-常规方法
- 【永艺XY椅】试用体验
- Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
- style中的scoped属性和lang属性
- Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
- Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
- Lefse analyzes the local implementation method with all installation files and details to ensure success.
- 如何高效读书学习
- Jenkins - Groovy Postbuild 插件丰富 Build History 信息
- 将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
猜你喜欢

Implementation of timed tasks in laravel framework

Jenkins - Groovy Postbuild 插件丰富 Build History 信息

1382. balancing binary search tree - General method

Self supervised learning and drug discovery

MapReduce elementary programming practice

面试官问:能否模拟实现JS的new操作符
![[Niuke discussion area] Chapter 4: redis](/img/53/f8628c65890f1c68cedab9008c1b84.png)
[Niuke discussion area] Chapter 4: redis

【嵌入式基础】串口通信

零基础多图详解图神经网络

Xctf attack and defense world misc wage earner advanced zone
随机推荐
Lefse analyzes the local implementation method with all installation files and details to ensure success.
Xctf attack and defense world misc wage earner advanced zone
Centos8 operation record command version Yum redis MySQL Nacos JDK
深入解析kubernetes controller-runtime
【sylixos】NEW_1 型字符驱动示例
【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
Database query optimization: master-slave read-write separation and common problems
9. Openfeign service interface call
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
PV操作原语
Review of drug discovery-03-molecular design and optimization
[Yocto RM]8 - OpenEmbedded Kickstart (.wks) Reference
COSCon'22 讲师征集令
The interviewer asked: this point of JS
面试官问:能否模拟实现JS的new操作符
205. isomorphic string
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
Cesium 点击获取经纬度(二维坐标)
【嵌入式基础】内存(Cache,RAM,ROM,Flash)
【永艺XY椅】试用体验