hashmap in js code example
Example 1: javascript map
array.map((item) => {
return item * 2
}
Example 2: javascript map
function listFruits() {
let fruits = ["apple", "cherry", "pear"]
fruits.map((fruit, index) => {
console.log(index, fruit)
})
}
listFruits()
Example 3: javascript hashmap
let contacts = new Map()
contacts.set('Jessie', {phone: "213-555-1234", address: "123 N 1st Ave"})
contacts.has('Jessie')
contacts.get('Hilary')
contacts.set('Hilary', {phone: "617-555-4321", address: "321 S 2nd St"})
contacts.get('Jessie')
contacts.delete('Raymond')
contacts.delete('Jessie')
console.log(contacts.size)
Example 4: map in js
const data = {name: "laptop", brands: ["dell", "acer", "asus"]}
let inside_data = data.brands.map((i) => {
console.log(i);
});
Example 5: map in javascript
['elem', 'another', 'name'].map((value, index, originalArray) => {
console.log(.....)
});