Array.prototype.map()
takes a second argument to set what this
refers to in the mapping function, so pass this
as the second argument to preserve the current context:
someList.map(function(item) {
...
}, this)
Alternatively, you can use an ES6 arrow function to automatically preserve the current this
context:
someList.map((item) => {
...
})