Untitled
unknown
javascript
3 years ago
652 B
9
Indexable
let arr =[2,4,5,6,8,2]; // [3,5,6,7,9,3]
let users=[{name:"nikhil" ,sirname:"lende"},{name:"ajay" ,sirname:"nagar"},{name:"sonali" ,sirname:"bendre"}];
// map function with array
// with normal function
function add(num){
return num +1;
};
let newarr =arr.map(add);
// with arrow function
let newarr2=arr.map((num)=>{
return num +2;
});
console.log("with normal function",newarr);
console.log("with array function",newarr2);
// map function with array of object
function usersdetail (user){
return console.log("name of user :",user.name,"Sirname of user :",user.sirname);
};
users.map(usersdetail);Editor is loading...