- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JavaScript Array.prototype.values()
The array.values() method of JavaScript returns a new Array Iterator object that contains the values for each index in the array.
The syntax is as follows −
arr.values()
Let us now implement the array.values() method in JavaScript −
Example
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <p>Click the button to display the value...</p> <button onclick="display()">Result</button> <p id="test"></p> <script> function display() { var arr = ['p', 'q', 'r']; var res = arr.values(); document.getElementById("test").innerHTML = res.next().value } </script> </body> </html>
Output
Click on the “Result” button −
Example
<!DOCTYPE html> <html> <body> <h2>Ranking Points</h2> <p>Click to display the points...</p> <button onclick="display()">Result</button> <p id="test"></p> <script> function display() { var points = ['10', '20', '30', '40', '50']; document.getElementById("test").innerHTML = (points.values()).next().value } </script> </body> </html>
Output
Click on the “Result” button −
- Related Articles
- JavaScript Array Ranking - JavaScript
- JavaScript JavaScript BOM Window Screen
- Fetching JavaScript keys by their values - JavaScript
- Sorting Array with JavaScript reduce function - JavaScript
- Deviations in two JavaScript arrays in JavaScript
- Remove elements from array using JavaScript filter - JavaScript
- JavaScript array.flatMap()
- JavaScript Array.isArray()
- JavaScript array.keys()
- JavaScript modules
- JavaScript array.values()
- JavaScript ArrayBuffer.isView()
- JavaScript Callbacks
- JavaScript Chart.js
- JavaScript Const

Advertisements