当前位置:网站首页>TypeScript数组乱序输出
TypeScript数组乱序输出
2022-07-02 12:46:00 【RemoteDev】
1. 目标数组 : let ak = [1,2,3,4,5];
2. 目标效果 : 随机乱序

3. 实现思路: 循环随机取数组一个元素,使用后,从数组删除该元素,随机范围为数组长度
while(ak.length>0){
let i = randomRangeInt(0,ak.length);
console.log(ak[i]);
ak.splice(i,1);//删除已使用项
}
边栏推荐
- [fluent] dart language (DART language features | JIT instant compilation | AOT static compilation)
- Leetcode -- number of palindromes
- Storage, reading and writing of blood relationship data of Nepal Graph & Data Warehouse
- idea 公共方法抽取快捷键
- Crawl the information of national colleges and universities in 1 minute and make it into a large screen for visualization!
- Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
- 华为云服务器安装mysqlb for mysqld.service failed because the control process exited with error code.See “sys
- 处理gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exitin
- Remove the underline in router link
- 隐藏在 Nebula Graph 背后的星辰大海
猜你喜欢

【5G NR】RRC连接释放

Solve * * warning * *: your ApplicationContext is unlikely to start due to a @componentscan of the defau

Processing gzip: stdin: not in gzip format: child returned status 1tar: error is not recoverable: exitin

Storage, reading and writing of blood relationship data of Nepal Graph & Data Warehouse

Add user-defined formula (time sharing t+0) to mobile app access as an example

End time processing method of wechat v3native payment settings

可视化技术在 Nebula Graph 中的应用

Another graduation season

Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals

idea 公共方法抽取快捷键
随机推荐
Vscade set multi line display of tab
/Bin/ld: cannot find -llz4
Idea public method extraction shortcut key
Ant group's large-scale map computing system tugraph passed the national evaluation
What is Amazon keyword index? The consequences of not indexing are serious
【题解】Educational Codeforces Round 82
Does bone conduction earphone have external sound? Advantages of bone conduction earphones
idea jar包冲突排查
Add user-defined formula (time sharing t+0) to mobile app access as an example
Vscode设置标签页多行显示
Song of cactus - throwing stones to ask the way (3)
QVariant与Json的各种纠葛——Qt
Boot 事务使用
Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network
仙人掌之歌——投石问路(3)
Introduction to Dynamic Planning II (5.647.62)
Traversal before, during and after binary tree
Practice of constructing ten billion relationship knowledge map based on Nebula graph
去除router-link中的下划线
Various entanglements between qvariant and Jason -- QT