TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript TypedArray entries() Method

JavaScript TypedArray entries() Method with example, join() method, javascript typedarray methods, keys() method, indexOf() method, includes() method, forEach() method, entries(), every(), find(), filter(), copyWithin() method etc.

<< Back to JAVASCRIPT

JavaScript TypedArray entries() Method

This method returns a new Array Iterator object that contains key/value pairs for each index in the array. For all item in the original array, the new iteration object will have an array with the index as the key and the item as the value.

What is Iterator?

An iterator is an object that have track of its current position, while accessing items in a collection one at a time.

An iterator returns an object with two properties: key and value.

Syntax:

array.entries ()

Parameters:

No parameters.

Return value:

A new Array Iterator object.

Browser Support:

Chrome 38
Edge Yes
Firefox 28
Opera No

Example 1

<script type="text/javascript">
// JavaScript to illustrate entries() method
 var array1 = ["javaTpoint","Core java","Advanced java"];


var iterator1 = array1.entries();


document.write(iterator1.next().value);

document.write("<br>")
// expected output: Array [0, "javaTpoint"]


document.write(iterator1.next().value);
// expected output: Array [1, "Core java"]

</script> 
Test it Now

Output:

[0, 'javaTpoint']
[1,'Core java']

Example 2

<script type="text/javascript">
// JavaScript to illustrate entries() method
// Input array
var a = ['Core Java', 'Python', 'Android'];
var iterator = a.entries();
for (let e of iterator) {
document.write("<br>") 
document.write(e);
}
// expected output
// [0, 'core Java']
// [1, 'Python']
// [2, 'Android'] 
</script>
Test it Now

Output:

 [0, 'core Java']
 [1, 'Python']
[2, 'Android']  





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf