这个 达雷。价值观() 是JavaScript中的一个内置函数,用于获取typedArray()内容的指定值。
null
语法:
typedArray.values()
参数 它不接受任何参数。
返回值: 它返回给定typedArray对象的指定值。
<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
这里的输出是未定义的,因为数组迭代器跨越了上限。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END