Open this example in the interactive library
Source code
const task = { id: 1 };
const metadata = new WeakMap([[task, { attempts: 2 }]]);
console.log(metadata.get(task).attempts);
Sample output
2

Open this example in the interactive library
const task = { id: 1 };
const metadata = new WeakMap([[task, { attempts: 2 }]]);
console.log(metadata.get(task).attempts);
2