Oh, whoops.
E.g.
I've edited that correction into my previous post~ 👋
clearStates is also used to initialise the _states array, so I should've checked to make sure _states exists here:
JavaScript:
const s = this._states.filter(hasTag); // get present tagged state IDs
JavaScript:
const s = this._states ? this._states.filter(hasTag) : []; // get present tagged state IDs