Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
JavaScript typedArray.toString() with Examples
Next article icon

JavaScript typedArray.entries() with Examples

Last Updated : 22 Dec, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The Javascript typedArray.entries() is an inbuilt function in JavaScript that gives a new array iterator object containing the key and value pairs of the given typedArray object. 

Syntax:

typedArray.entries()

Parameter: It does not accept any parameters. 

Return value It returns a new array iterator object containing the key and value pairs of the given typedArray object.

JavaScript examples to show the working of this function:

Example 1: In this example, we will use the typedArray.entries() function to return the key and value pairs of the object.

javascript




<script>
    // Creating a typedArray Uint8Array() with some elements
    const uint8 = new Uint8Array([ 5, 10, 15, 20, 25, 30 ]);
      
    // Calling entries() function
    A = uint8.entries();
      
    // Shifting array iterator to next element one by one
    // Iterator assigned to 10
    A.next();
      
    // Iterator assigned to 15
    A.next();
      
    console.log(A.next().value);
</script>
 
 

Output: Here 2 is the index of element 15.

2, 15

 Example 2: Here output is undefined because iterator exceeds the upper bound.

javascript




<script>
    // Creating a typedArray Uint8Array() with some elements
    const uint8 = new Uint8Array([ 5, 10, 15, 20, 25 ]);
      
    // Calling entries() function
    A = uint8.entries();
      
    // Shifting array iterator to next element one by one
    // Iterator assigned to 10
    A.next();
      
    // Iterator assigned to 15
    A.next();
      
    // Iterator assigned to 20
    A.next();
      
    // Iterator assigned to 25
    A.next();
      
    // Iterator went out of index
    A.next();
    console.log(A.next().value);
</script>
 
 

Output:

undefined


Next Article
JavaScript typedArray.toString() with Examples

S

ShivamKD
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • javascript-functions
  • javascript-typedArray

Similar Reads

  • JavaScript typedArray.values() with Examples
    The Javascript typedArray.values() is an inbuilt function in JavaScript that is used to get the specified value of the contents of the typedArray(). Syntax: typedArray.values() Parameters It does not accept any parameters. Return value: It returns the specified value of the given typedArray object.
    2 min read
  • JavaScript typedArray.filter() with Example
    The Javascript typedArray.filter() is an inbuilt function in javascript that is used to form a new typedArray with the elements which satisfy the test implemented by the function provided. Syntax: typedarray.filter(callback) Parameters: It takes the parameter "callback" function which checks each el
    2 min read
  • JavaScript typedArray.@@species with Example
    The typedArray.@@species is an inbuilt property in JavaScript that is used to return the constructor of the given typedArray. The typedArray is of many types like: Int8Array();Int16Array();Uint32Array();Uint8Array();Uint16Array();Float32Array();Uint8ClampedArray();Int32Array();Float64Array(); Syntax
    1 min read
  • JavaScript typedArray.toString() with Examples
    The Javascript typedArray.toString() is an inbuilt function in JavaScript that is used to convert the contents of the tyepdArray into a string. Syntax: typedarray.toString() Parameters: This function does not accept any parameter. Return value: It returns a string that represents the elements of the
    1 min read
  • JavaScript typedArray.subarray() with Examples
    The Javascript typedArray.subarray() is an inbuilt function in JavaScript that is used to return a part of the typedArray object. Syntax:typedarray.subarray(begin, end);Parameters: begin: It specifies the index of the starting element from which the part of the given array is to be started. It is op
    2 min read
  • JavaScript typedArray.@@iterator
    The typedArray.@@iterator is an inbuilt property in JavaScript which is used to return the initial value of the given typedArray's element. Syntax: arr[Symbol.iterator]() Parameters: It does not accept any parameter because it is a property not a function. Return value: It returns the array iterator
    1 min read
  • JavaScript typedArray.includes() Method
    The typedArray.includes() is an inbuilt function in JavaScript which is used to check whether a particular element is included by the given typedArray or not and accordingly it returns true and false. Syntax: typedarray.includes(Element, Index); Parameters: It accepts two parameter which are specifi
    2 min read
  • JavaScript typedArray.fill() Method
    The typedArray.fill() is an inbuilt function in JavaScript which is used to fill a value to typedArray from a start index to end index. Syntax: typedarray.fill(value, start, end) Parameters: It takes three parameters that are specified below- value: It is the value to fill with typed array.start: It
    1 min read
  • JavaScript typedArray.indexOf() Method
    The typedArray.indexOf() is an inbuilt function in JavaScript which is used to return the index of the element if found in the given typedArray otherwise it returns -1. Syntax: typedarray.indexOf(Element, Index); Parameters: It accepts two parameter which are specified below- Element: It is the elem
    2 min read
  • JavaScript typedArray.from() Property
    The typedArray.from() is an inbuilt function in JavaScript which is used to construct a new typedArray from a normal array or any iterable object. List of different typedArrays are specified in the table below: Int8Array();Int16Array();Uint32Array();Uint8Array();Uint16Array();Float32Array();Uint8Cla
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences