TypedArray values()
JavaScript TypedArray values()方法
JavaScript values()方法用于定义数组中内容的值。
语法:
参数:
无参数
返回值:
索引值
浏览器支持:
浏览器 |
版本 |
Chrome |
是 |
Safari |
是 |
Firefox |
是 |
Opera |
是 |
示例1
JavaScript TypedArray values()方法。
<script>
//JavaScript to illustrate types() method
var A = new Uint8Array([ 1,3,4,5,6,7,8,9 ]);
// Calling array.values() method
var lidihuo = A.values();
// Printing value of index 0
document.write(lidihuo.next().value);
// expected output:1
</script>
输出:
示例2
JavaScript TypedArray values()方法。
<script>
//JavaScript to illustrate types() method
var A = new Uint8Array([ 1,3,4,5,6,7,8,9 ]);
// Calling array.values() method
var lidihuo = A.values();
// shift index to the 1
lidihuo.next();
// Printing the value of index 1
document.write(lidihuo.next().value);
// expected output:3
</script>
输出:
示例3
JavaScript TypedArray values()方法。
<script>
//JavaScript to illustrate types() method
var A = new Uint8Array([ 1,3,4,5,6,7,8,9 ]);
// Calling array.values() method
var lidihuo = A.values();
lidihuo.next()
lidihuo.next()
lidihuo.next()
lidihuo.next()
lidihuo.next()
lidihuo.next()
lidihuo.next()
lidihuo.next()
document.write(lidihuo.next().value);
// expected output:undefined
</script>
输出: