Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
652 B
1
Indexable
Never
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);