I have strange but interesting question and I will start right from examples.
Imagine I have an object which looks like that:
const stringEvaluate = {
toString: () => 'Im object'
}
Now I can create string using this object
stringEvaluate + ' stringified'
// Im object stringified
And also I can do something like that:
const numberEvaluate = {
valueOf: () => 1337
}
And turn this object into:
numberEvaluate + 682
// 2019
My questions is: Can I override some object property which will help me to do something like that:
const evaluatedObject = {
someProperty: () => 'I was object, but not now'
}
const magic = evaluatedObject
console.log(magic)
//'I was object, but not now'