how to map a object in javascript code example
Example 1: map through keys javascript
var myObject = { 'a': 1, 'b': 2, 'c': 3 };
Object.keys(myObject).map(function(key, index) {
myObject[key] *= 2;
});
console.log(myObject);
Example 2: javascript map
array.map((item) => {
return item * 2
}
Example 3: map in js
const data = {name: "laptop", brands: ["dell", "acer", "asus"]}
let inside_data = data.brands.map((i) => {
console.log(i);
});
Example 4: javascript map
const numbers = [0,1,2,3];
console.log(numbers.map((number) => {
return number;
}));