Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-uni-app-x-zh
提交
50f20b4d
U
unidocs-uni-app-x-zh
项目概览
DCloud
/
unidocs-uni-app-x-zh
通知
144
Star
2
Fork
33
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
9
列表
看板
标记
里程碑
合并请求
11
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
unidocs-uni-app-x-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
9
Issue
9
列表
看板
标记
里程碑
合并请求
11
合并请求
11
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
50f20b4d
编写于
9月 02, 2024
作者:
M
mahaifeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[array]去除手动生成的代码
上级
dfd753bf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
132 deletion
+13
-132
docs/uts/buildin-object-api/array.md
docs/uts/buildin-object-api/array.md
+13
-132
未找到文件。
docs/uts/buildin-object-api/array.md
浏览文件 @
50f20b4d
...
@@ -167,15 +167,7 @@ let arr = new Array(10)
...
@@ -167,15 +167,7 @@ let arr = new Array(10)
<!-- UTSJSON.Array.findIndex.returnValue -->
<!-- UTSJSON.Array.findIndex.returnValue -->
```
ts
<!-- UTSJSON.Array.findIndex.test -->
const
array1
=
[
5
,
12
,
8
,
130
,
44
];
const
isLargeNumber
=
(
element
:
number
):
boolean
=>
element
>
13
;
console
.
log
(
array1
.
findIndex
(
isLargeNumber
));
// expected output: 3
```
<!-- UTSJSON.Array.findIndex.compatibility -->
<!-- UTSJSON.Array.findIndex.compatibility -->
...
@@ -215,21 +207,7 @@ console.log(array1.findIndex(isLargeNumber));
...
@@ -215,21 +207,7 @@ console.log(array1.findIndex(isLargeNumber));
<!-- UTSJSON.Array.fill.returnValue -->
<!-- UTSJSON.Array.fill.returnValue -->
```
ts
<!-- UTSJSON.Array.fill.test -->
const
array1
=
[
1
,
2
,
3
,
4
];
// fill with 0 from position 2 until position 4
console
.
log
(
array1
.
fill
(
0
,
2
,
4
));
// expected output: [1, 2, 0, 0]
// fill with 5 from position 1
console
.
log
(
array1
.
fill
(
5
,
1
));
// expected output: [1, 5, 5, 5]
console
.
log
(
array1
.
fill
(
6
));
// expected output: [6, 6, 6, 6]
```
需要注意的是,截止HBuilder 4.22 部分平台尚不支持
[
根据元素个数构造`Array`的写法
](
https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/array.html#constructor
)
需要注意的是,截止HBuilder 4.22 部分平台尚不支持
[
根据元素个数构造`Array`的写法
](
https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/array.html#constructor
)
...
@@ -259,15 +237,7 @@ for(let i = 0; i < 20; i++){
...
@@ -259,15 +237,7 @@ for(let i = 0; i < 20; i++){
<!-- UTSJSON.Array.copyWithin.returnValue -->
<!-- UTSJSON.Array.copyWithin.returnValue -->
```
ts
<!-- UTSJSON.Array.copyWithin.test -->
const
array1
=
[
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
,
'
e
'
];
// copy to index 0 the element at index 3
console
.
log
(
array1
.
copyWithin
(
0
,
3
,
4
));
// expected output: Array ["d", "b", "c", "d", "e"]
// copy to index 1 all elements from index 3 to the end
console
.
log
(
array1
.
copyWithin
(
1
,
3
));
// expected output: Array ["d", "d", "e", "d", "e"]
```
<!-- UTSJSON.Array.copyWithin.compatibility -->
<!-- UTSJSON.Array.copyWithin.compatibility -->
...
@@ -279,21 +249,7 @@ console.log(array1.copyWithin(1, 3));
...
@@ -279,21 +249,7 @@ console.log(array1.copyWithin(1, 3));
<!-- UTSJSON.Array.pop.returnValue -->
<!-- UTSJSON.Array.pop.returnValue -->
```
ts
<!-- UTSJSON.Array.pop.test -->
const
plants
=
[
'
broccoli
'
,
'
cauliflower
'
,
'
cabbage
'
,
'
kale
'
,
'
tomato
'
];
console
.
log
(
plants
.
pop
());
// expected output: "tomato"
console
.
log
(
plants
);
// expected output: Array ["broccoli", "cauliflower", "cabbage", "kale"]
plants
.
pop
();
console
.
log
(
plants
);
// expected output: Array ["broccoli", "cauliflower", "cabbage"]
```
<!-- UTSJSON.Array.pop.compatibility -->
<!-- UTSJSON.Array.pop.compatibility -->
...
@@ -305,20 +261,7 @@ console.log(plants);
...
@@ -305,20 +261,7 @@ console.log(plants);
<!-- UTSJSON.Array.push.returnValue -->
<!-- UTSJSON.Array.push.returnValue -->
```
ts
<!-- UTSJSON.Array.push.test -->
const
animals
=
[
'
pigs
'
,
'
goats
'
,
'
sheep
'
];
const
count
=
animals
.
push
(
'
cows
'
);
console
.
log
(
count
);
// expected output: 4
console
.
log
(
animals
);
// expected output: Array ["pigs", "goats", "sheep", "cows"]
animals
.
push
(
'
chickens
'
,
'
cats
'
,
'
dogs
'
);
console
.
log
(
animals
);
// expected output: Array ["pigs", "goats", "sheep", "cows", "chickens", "cats", "dogs"]
```
<!-- UTSJSON.Array.push.compatibility -->
<!-- UTSJSON.Array.push.compatibility -->
...
@@ -330,13 +273,7 @@ console.log(animals);
...
@@ -330,13 +273,7 @@ console.log(animals);
<!-- UTSJSON.Array.concat.returnValue -->
<!-- UTSJSON.Array.concat.returnValue -->
```
ts
<!-- UTSJSON.Array.concat.test -->
const
array1
=
[
'
a
'
,
'
b
'
,
'
c
'
];
const
array2
=
[
'
d
'
,
'
e
'
,
'
f
'
];
const
array3
=
array1
.
concat
(
array2
);
console
.
log
(
array3
);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
```
<!-- UTSJSON.Array.concat.compatibility -->
<!-- UTSJSON.Array.concat.compatibility -->
...
@@ -348,6 +285,8 @@ console.log(array3);
...
@@ -348,6 +285,8 @@ console.log(array3);
<!-- UTSJSON.Array.concat_1.returnValue -->
<!-- UTSJSON.Array.concat_1.returnValue -->
<!-- UTSJSON.Array.concat_1.test -->
<!-- UTSJSON.Array.concat_1.compatibility -->
<!-- UTSJSON.Array.concat_1.compatibility -->
### join(separator?)
### join(separator?)
...
@@ -358,19 +297,7 @@ console.log(array3);
...
@@ -358,19 +297,7 @@ console.log(array3);
<!-- UTSJSON.Array.join.returnValue -->
<!-- UTSJSON.Array.join.returnValue -->
```
ts
<!-- UTSJSON.Array.concat_1.test -->
const
elements
=
[
'
Fire
'
,
'
Air
'
,
'
Water
'
];
console
.
log
(
elements
.
join
());
// expected output: "Fire,Air,Water"
console
.
log
(
elements
.
join
(
''
));
// expected output: "FireAirWater"
console
.
log
(
elements
.
join
(
'
-
'
));
// expected output: "Fire-Air-Water"
```
<!-- UTSJSON.Array.join.compatibility -->
<!-- UTSJSON.Array.join.compatibility -->
...
@@ -392,18 +319,7 @@ console.log(elements.join('-'));
...
@@ -392,18 +319,7 @@ console.log(elements.join('-'));
<!-- UTSJSON.Array.shift.returnValue -->
<!-- UTSJSON.Array.shift.returnValue -->
```
ts
<!-- UTSJSON.Array.concat_1.test -->
const
array1
=
[
1
,
2
,
3
];
const
firstElement
=
array1
.
shift
();
console
.
log
(
array1
);
// expected output: Array [2, 3]
console
.
log
(
firstElement
);
// expected output: 1
```
<!-- UTSJSON.Array.shift.compatibility -->
<!-- UTSJSON.Array.shift.compatibility -->
...
@@ -415,27 +331,7 @@ console.log(firstElement);
...
@@ -415,27 +331,7 @@ console.log(firstElement);
<!-- UTSJSON.Array.slice.returnValue -->
<!-- UTSJSON.Array.slice.returnValue -->
```
ts
<!-- UTSJSON.Array.slice.test -->
const
animals
=
[
'
ant
'
,
'
bison
'
,
'
camel
'
,
'
duck
'
,
'
elephant
'
];
console
.
log
(
animals
.
slice
(
2
));
// expected output: Array ["camel", "duck", "elephant"]
console
.
log
(
animals
.
slice
(
2
,
4
));
// expected output: Array ["camel", "duck"]
console
.
log
(
animals
.
slice
(
1
,
5
));
// expected output: Array ["bison", "camel", "duck", "elephant"]
console
.
log
(
animals
.
slice
(
-
2
));
// expected output: Array ["duck", "elephant"]
console
.
log
(
animals
.
slice
(
2
,
-
1
));
// expected output: Array ["camel", "duck"]
console
.
log
(
animals
.
slice
());
// expected output: Array ["ant", "bison", "camel", "duck", "elephant"]
```
<!-- UTSJSON.Array.slice.compatibility -->
<!-- UTSJSON.Array.slice.compatibility -->
...
@@ -447,11 +343,7 @@ console.log(animals.slice());
...
@@ -447,11 +343,7 @@ console.log(animals.slice());
<!-- UTSJSON.Array.sort.returnValue -->
<!-- UTSJSON.Array.sort.returnValue -->
```
ts
<!-- UTSJSON.Array.sort.test -->
const
array2
=
[
5
,
1
,
4
,
2
,
3
];
array2
.
sort
((
a
:
number
,
b
:
number
):
number
=>
a
-
b
);
// expect(array2).toEqual([1, 2, 3, 4, 5]);
```
<!-- UTSJSON.Array.sort.compatibility -->
<!-- UTSJSON.Array.sort.compatibility -->
...
@@ -479,18 +371,7 @@ a.sort((a, b) : number => {
...
@@ -479,18 +371,7 @@ a.sort((a, b) : number => {
<!-- UTSJSON.Array.splice.returnValue -->
<!-- UTSJSON.Array.splice.returnValue -->
```
ts
<!-- UTSJSON.Array.splice.test -->
const
months
=
[
'
Jan
'
,
'
March
'
,
'
April
'
,
'
June
'
];
months
.
splice
(
1
,
0
,
'
Feb
'
);
// inserts at index 1
console
.
log
(
months
);
// expected output: Array ["Jan", "Feb", "March", "April", "June"]
months
.
splice
(
4
,
1
,
'
May
'
);
// replaces 1 element at index 4
console
.
log
(
months
);
// expected output: Array ["Jan", "Feb", "March", "April", "May"]
```
<!-- UTSJSON.Array.splice.compatibility -->
<!-- UTSJSON.Array.splice.compatibility -->
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录