What is Map ?
Map is a collection of key and value pairs, similar to Object. The main difference between a Map and an Object is that Map allows key on any type either primitive or an object. Let’s learn how to create a Map and do operations on it.
var array = ["this is react js","<br>",999,"<br>",9];
var abc = array.map((value)=>{
console.log(value);
document.write(value)
});
console.log(abc);
Object with Map() method
<script>
var abc =[
{
sname:"ramesh",
course:"rjs",
addrress:"bangalore",
},
{
sname:"ramesh",
course:"rjs",
addrress:"bangalore",
},
{
sname:"ramesh",
course:"rjs",
addrress:"bangalore",
},
{
sname:"ramesh",
course:"rjs",
addrress:"bangalore",
}
]
var msg = abc.map((value)=>{
return value.sname;
});
document.write(msg);
console.log(msg);
var course = abc.map((course)=>{
return course.course;
})
document.write(course);
console.log(course);
</script>
details plz visit us @ https://codeguruva.blogspot.com/
Top comments (0)