当前位置:网站首页>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);//删除已使用项
}
边栏推荐
- How to import a billion level offline CSV into Nepal graph
- Remove the underline in router link
- Traversal before, during and after binary tree
- 如何实现十亿级离线 CSV 导入 Nebula Graph
- 纪念成为首个 DAYU200 三方 demo 贡献者
- 注册成为harmonyos开发者并安装DevEco Studio 3.0 Beta2 for HarmonyOS
- PyC file decompile
- Introduction to database system Chapter 1 short answer questions - how was the final exam?
- 处理gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exitin
- /Bin/ld: cannot find -lgssapi_ krb5
猜你喜欢

Boot 事务使用

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

Route service grid traffic through two-level gateway design

关于mysql安装的一些问题

Construction and business practice of Zhongke brain knowledge map platform

又是一年毕业季

Compress words (kmp/ string hash, double hash)

Figure database | Nepal graph v3.1.0 performance report

Introduction to Dynamic Planning II (5.647.62)

Pandora IOT development board learning (RT thread) - Experiment 2 RGB LED experiment (learning notes)
随机推荐
隐藏在 Nebula Graph 背后的星辰大海
The sea of stars hidden behind the nebula graph
Effectively use keywords to increase Amazon sales
Invalid bound statement (not found)解决方法总结
Recommended practice sharing of Zhilian recruitment based on Nebula graph
Pyobject to char* (string)
Song of cactus - throwing stones to ask the way (3)
2022 the latest and most detailed will successfully set the background image in vscade and solve unsupported problems at the same time
Digital collection system development (program development) - Digital Collection 3D modeling economic model system development source code
Ssh/scp does not prompt all activities are monitored and reported
Boot 中bean配置覆盖
Wavedec2 in MATLAB, talk about the wavedec2 function [easy to understand]
全方位解读服务网格(Service Mesh)的背景和概念
Dimension table and fact table in data warehouse
构建多架构镜像的最佳实践
How to use percona tool to add fields to MySQL table after interruption
Leetcode --- longest public prefix
纪念成为首个 DAYU200 三方 demo 贡献者
【5G NR】RRC连接释放
GraphX 图计算实践之模式匹配抽取特定子图