arrays[1]
arrays[1]
map - it takes a function on how to transforms the values and return a new array
console.log(hobbies.map(hobby => {
retun 'hobby:' +hobby;
}));
hobbies.push('programming');
Note: always copy and edit the array instead of adding new array to the existing
one
ways to copy the array
const person = {
name: 'pawan',
age: 12,
greet() {
console.log('hi there');
}
};
rest operator
merge multiple args into an array and used in argument list of an function
const toArray = (...args) => args;
console.log(toArray(1,2,3,4));