typedArray.values()是JavaScript中的内置函数, 用于获取typedArray()的内容的指定值。
语法如下:
typedArray.values()
参数它不接受任何参数。
返回值:它返回给定typedArray对象的指定值。
JavaScript代码显示此功能的工作方式:
代码1:
<
script>
//Constructing a new typedArray Uint8Array() with some value.
const A = new Uint8Array([ 5, 10, 15, 20, 25, 30 ]);
//Calling typedArray.values() function.
const B = A.values();
//Shifting array iterator to next element
//iterator assigned to 10
B.next();
//iterator assigned to 15
B.next();
//iterator assigned to 20
B.next();
//Printing value 20
document.write(B.next().value);
<
/script>
输出如下:
20
代码2:
<
script>
//Constructing a new typedArray Uint8Array() with some value.
const A = new Uint8Array([5, 10, 15, 20, 25, 30]);
//Calling typedArray.values() function.
const B = A.values();
//Shifting array iterator to next element
//iterator assigned to 10
B.next();
//iterator assigned to 15
B.next();
//iterator assigned to 20
B.next();
//iterator assigned to 25
B.next();
//iterator assigned to 30
B.next();
//Now iterator go beyond the index
B.next();
document.write(B.next().value);
<
/script>
输出如下:
undefined
【JavaScript typedArray.values()用法示例】这里的输出是不确定的, 因为数组迭代器越过了上限。
推荐阅读
- MongoDB Update()方法用法示例介绍
- JavaScript typeof运算符用法介绍
- JavaScript ‘===’和‘==’比较运算符
- JavaScript weakMap.delete()方法用法示例
- JavaScript weakMap.get()方法用法示例
- 本图文详细教程教你Ghost win1064位娘桌面系统壁纸大全
- 本图文详细教程教你Ghost windows10系统旗舰版永久激活密
- 一键Ghost win10系统永久激活工具最新推荐
- win10系统安装ie10 64位图文详细教程图解