JavaScript 中的 TypedArray.fill() 函数
TypedArray 对象的 fill() 函数用指定值(固定)替换数组中所有必需的/需要的元素。此函数接受三个数字,一个表示固定值,另外两个表示待替换元素部分的开始和结束索引(结束值是可选的)。
语法
其语法如下
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
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP