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
The issue here might be because of the
Objectin the prototype chain. In JavaScript, will return , and any object that is an instance of will have that string in its prototype chain. So, even if is an instance of , it will pass the check if it also has in its prototype chain, which it will because all objects in JavaScript do.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.