这个 大堆values()函数 是JavaScript中的一个内置函数,用于返回一个新的数组迭代器对象,该对象包含数组中每个索引的值,即打印数组的所有元素。 语法:
null
arr.values()
返回值: 它返回一个新的数组迭代器对象,即给定数组的元素。 例如:
Input:A = ['a', 'b', 'c', 'd']Output:a, b, c, dHere as we see that input array contain some elements and in output same elements get printed.
让我们看看数组上的JavaScript程序。values()函数:
JavaScript
// Input array contain some elements var A = [ 'Ram' , 'Z' , 'k' , 'geeksforgeeks' ]; // Here array.values() function is called. var iterator = A.values(); // All the elements of the array the array // is being printed. console.log(iterator.next().value); console.log(iterator.next().value); console.log(iterator.next().value); console.log(iterator.next().value); |
输出:
> Ram, z, k, geeksforgeeks
申请: 这个阵列。JavaScript中的values()函数用于打印给定数组的元素。 让我们看看数组上的JavaScript程序。values()函数:
JavaScript
// Input array contain some elements. var array = [ 'a' , 'gfg' , 'c' , 'n' ]; // Here array.values() function is called. var iterator = array.values(); // Here all the elements of the array is being printed. for (let elements of iterator) { console.log(elements); } |
输出:
> a, gfg, c, n
支持的浏览器:
- 谷歌Chrome 66及以上版本
- 微软Edge 12及以上
- Firefox 60及以上版本
- 53岁及以上
- Safari 9及以上
JavaScript最为人所知的是网页开发,但它也用于各种非浏览器环境。通过以下步骤,您可以从头开始学习JavaScript JavaScript教程 和 JavaScript示例 .
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END