Right now, I'm doing something like this:
var myObject = {}
const action = () => {
console.log("say hello")
}
myObject.act = action
This results in the output:
say hello
But is there a faster way to do this, like a const lambda (or something)?
Much like:
// This is psuedocode.
myObject.myConstAction = const lambda (){
console.log("I won't change.")
}
I would hope the property .myConstAction cannot be reassigned or overwritten.
Object.defineProperty(myObject, "act", {writable: false, enumerable: true, configurable: false, value: () => console.log("say hello")});.constdoesn’t help here.