Top "Instanceof" questions

instanceof is an operator available in some object-oriented languages, including Java, php and JavaScript.

What is the C# equivalent to Java's isInstance()?

I know of is and as for instanceof, but what about the reflective isInstance() method?

c# reflection introspection instanceof
Avoiding instanceof in Java

Having a chain of "instanceof" operations is considered a "code smell". The standard answer is "use polymorphism". How would I …

java reflection polymorphism instanceof chain-of-responsibility
Why does 'instanceof' in TypeScript give me the error "'Foo' only refers to a type, but is being used as a value here."?

I wrote this code interface Foo { abcdef: number; } let x: Foo | string; if (x instanceof Foo) { // ... } But TypeScript gave me …

javascript typescript instanceof
Javascript !instanceof If Statement

This is a really basic question really just to satisfy my curiosity, but is there a way to do something …

javascript instanceof
Example of ´instanceof´

public class TableModel2 extends TableModel1 { ... } TableModel2 tableModel = new TableModel2(); boolean t1 = tableModel instanceof TableModel1; boolean t2 = tableModel instanceof TableModel2; In …

java instanceof
How instanceof will work on an interface

instanceof can be used to test if an object is a direct or descended instance of a given class. instanceof …

java interface instanceof
Check instanceof in stream

I have the following expression: scheduleIntervalContainers.stream() .filter(sic -> ((ScheduleIntervalContainer) sic).getStartTime() != ((ScheduleIntervalContainer)sic).getEndTime()) .collect(Collectors.toList()); ...…

java java-8 java-stream instanceof
Switch over type in java

Before I start, I know there are a bunch of answers to this question that suggest alternate approaches. I'm looking …

java types enums switch-statement instanceof
How can I reduce the Cyclomatic Complexity of this?

I have a method that receives an Object and does something based on what type of object it detects: void …

java refactoring instanceof cyclomatic-complexity
Differences between typeof and instanceof in JavaScript

I'm working with node.js, so this could be specific to V8. I've always noticed some weirdness with differences between …

javascript node.js syntax instanceof typeof