I am an experienced C++ developer but new to JavaScript. I want to write an ES6 JavaScript class that maintains state.
How do I tell when state has changed?
I can think of two ways to do this. One way is to inspect an instance of the class to see if it is "dirty" since the last time it was marked "clean". I.e. mark an instance object as clean and changing any data member of the class marks it as dirty. Or be able to compare two instances of the same class. If an incoming state does not equal a known state then state has changed. I know this is not built into JavaScript.
What is the best way to do this in JavaScript? I am working in Typescript if it makes a difference.