Object
const taskObjects = {
task: 'code',
date: 'today',
repeat: true
}
console .log(taskObjects)
//{task: "code", date: "today", repeat: true}
More "traditional" key/value
Easier to write and access values with . and [ ]
Use when you need to include
Functions
(methods)
Use when working with JSON (can convert to map)
Maps
const taskMaps = new Map( [
['task', 'code'],
['date', 'today'],
[false, 'start coding!'],
]);
console .log(taskMaps)
//{"task" => "code", "date" => "today", false => "start coding!"}
Better performance
Keys can have any data type
Easy to iterate
Easy to compute size
Use when you simply need to map key to values
Use when you need key that are
not
strings