instanceof yields inconsistent results for detecting interfaces?

Is there anything tricky I should know about `instanceof`? I'm passing a list of objects through a few methods and testing whether these objects implement a particular interface using `instanceof`. In some cases, `instanceof` correctly identifies objects as implementing the interface, in other cases it doesn't. It appears to be giving me inconsistent results on the same object in different places. Is there any trick/gotcha I should be aware of here? In anticipation of comments you might have: 1) I know `instanceof` is bad form. I'm working with a less-than-perfect object hierarchy that can't be changed, and this is the least bad thing I can think to do. 2) I'm working to create a code example, but I'll need to simplify my code a lot if I'm going to paste in anything useful here. In the meantime, if you've seen this before and can shed some light, please do.
Any chance of getting a code sample?

以上就是instanceof yields inconsistent results for detecting interfaces?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准