當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


JavaScript TypedArray values()用法及代碼示例


JavaScript values() 方法用於定義數組中內容的值。

用法:

array.values()

參數:

沒有參數

返回值:

index 值

瀏覽器支持:

Chrome Yes
Safari Yes
Firefox Yes
Opera Yes

例子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 JavaTpoint = A.values();
   // Printing value of index 0
   document.write(JavaTpoint.next().value);
    // expected output:1
</script>

輸出:

1

例子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 JavaTpoint = A.values();
// shift index to the 1 
JavaTpoint.next();
   // Printing the value of index 1
   document.write(JavaTpoint.next().value);
    // expected output:3
</script>

輸出:

3

例子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 JavaTpoint = A.values();
       JavaTpoint.next()
       JavaTpoint.next()
       JavaTpoint.next()
       JavaTpoint.next()
       JavaTpoint.next()
       JavaTpoint.next()
       JavaTpoint.next()
       JavaTpoint.next()
   document.write(JavaTpoint.next().value);
    // expected output:undefined
</script>

輸出:

Undefined






相關用法


注:本文由純淨天空篩選整理自 JavaScript TypedArray values() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。