无涯教程-Javascript - values()函数

35 阅读1分钟

JavaScript values()方法用于定义数组中内容的值。

values - 语法

array.values()

values - 返回值

返回数组值

values - 浏览器支持

Chrome
Safari
Firefox
Opera

values - 例子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

values - 例子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

values - 例子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

参考链接

www.learnfk.com/javascript/…