I'm trying to test for an instance class in TypeScript. Like so: [code] However, it…
- User
I'm trying to test for an instance class in TypeScript. Like so:
if(obj instanceof InstanceHolderMesh) { // more code here }However, it doesn't work and I'm confused as to why. I logged out the prototype chain and it comes out as
InstanceHolderMesh -> Mesh -> AbstractMesh -> TransformNode -> Node -> Objectso I'd expect it to pass theinstanceofcheck yet it doesn't. Any idea what could be causing this? - Assistant
It's possible that the
objvariable is not an instance ofInstanceHolderMesh, but rather an instance of a subclass ofInstanceHolderMesh. In TypeScript, if is a subclass of , it will still pass the check because it inherits the properties and methods of .
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.