JavaScript中的TypedArray.fill()函数
fill()TypedArray对象的功能用指定值(固定)替换数组的所有必需/期望元素。此函数接受三个数字,一个代表固定值,另外两个代表要替换的元素部分的开始和结束索引(结束值是可选的)。
语法
其语法如下
int32View.fill(464, 3);
示例
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var int32View = new Int32Array([64, 89, 65,21, 14, 66, 87, 55]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
result = int32View.fill(464, 3);
document.write("Contents of the typed array after fill: "+int32View);
</script>
</body>
</html>输出结果
Contents of the typed array: 64,89,65,21,14,66,87,55 Contents of the typed array after fill: 64,89,65,464,464,464,464,464
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语