Beginner Friendly · Hands-on · Free

Returns an array with arrays of the key, value pairs

Javascript இல் Object.entries() method இங்கு ஒரு object க்கு உரிய enumerable property அதாவது key மற்றும் value array வாக return செய்கிறது. அதாவது [key, value] என்ற order இல் return செய்கிறது

5 min read Updated Dec 13, 2025

JavaScript Object.entries() Method

Javascript இல் Object.entries() method இங்கு ஒரு object க்கு உரிய enumerable property அதாவது key மற்றும் value array வாக return செய்கிறது. அதாவது [key, value] என்ற order இல் return செய்கிறது.

Object.entries(obj)

Note: இங்கு Object.entries() method இங்கு properties களை கொண்ட ஒரு object ஆனது argument ஆக அனுப்பப்படுகிறது. இந்த function key மற்றும் value array வாக return செய்கிறது. அதாவது [key, value] என்ற order இல் return செய்கிறது. இந்த iterable array ஐ கொண்டு நமக்கு தேவையான values களை எடுத்து கொள்ளலாம்.

Example1

<script>
const animals = {
    1:"lion",
    2:"tiger",
    3:"peapock"
   };  
var res = Object.entries(animals);  
document.writeln(res);
</script>

மேலே உள்ள Example1-ஐ கவனிக்கவும் இங்கு Object.entries() method இல் animals என்ற object ஆனது argument ஆக அனுபப்படுகிறது. இங்கு animals என்ற object க்கு {1,"lion",2,"tiger",3,"peapock"} என்ற properties கள் உள்ளன. Object.entries() method ஆனது இந்த enumerable property ஐ ஒரு iterable array வாக convert செய்து நமக்கு output ஆக கொடுக்கிறது. எனவே நமக்கு output [1,"lion"],[2,"tiger"],[3,"peapock"] என கிடைக்கிறது.

Output:

[1,"lion"],[2,"tiger"],[3,"peapock"]

Example2

<script>
  const birds = {
    1:"peacock",
    2:"hen",
    3:"parrot"
   };  
var res = Object.entries(birds);  
document.writeln(res[2]);  
</script>

மேலே உள்ள Example2-ஐ கவனிக்கவும் இங்கு Object.entries() method இல் animals என்ற birds ஆனது argument ஆக அனுபப்படுகிறது. இங்கு birds என்ற object க்கு {1:"peacock",2:"hen",3:"parrot"} என்ற properties கள் உள்ளன. Object.entries() method ஆனது இந்த enumerable property ஐ ஒரு iterable array வாக convert செய்து நமக்கு output ஆக கொடுக்கிறது. இங்கு நாம் convert செய்த values ஐ res என்ற variable இல் store செய்கிறோம். இங்கு index 2 அதாவது res[2] என்பதை print செய்து பார்க்கும் போது output [3:"parrot"] என கிடைக்கிறது.

Output:

[3:"parrot"]

இது பற்றிய தங்களின் கருத்துகளை இங்கே பதிவிடுங்கள் . இது பயனுள்ளதாக விரும்பினால் மற்றவர்களுக்கும் இதை share செய்யுங்கள்.