I have a situation where I am using a typescript code repeatedly and I want to find a way to make it more efficient by reusing the code through assigning it to a variable. An example of this is defining an arrow function within the map function to return an object, and I would like to explore the best approach to reuse this object.
Here is a snippet of the code:
let options: kendo.ui.GridOptions = {
dataSource: {
// Code here
},
columns: [
// Code here
]
}
The specific part of the code that I am aiming to optimize is:
.map(x => {
return {
assetClassificationId: x.assetClassificationId,
assetTypeName: x.assetTypeName,
assetSubTypeName: x.assetSubTypeName,
assetClassificationName: x.assetClassificationName,
classificationHiddenFromUser: x.classificationHiddenFromUser
}
})
Is there a way to reuse this object within the map function?