今まで意識して使ったことがなかったが
どこかで役立つかも。

instanceof 演算子

instanceof 演算子

object instanceof classConstructor

object が classConstructor のインスタンスまたは classConstructor のサブクラスであるかどうかをテストします。instanceof 演算子は、プリミティブタイプをラッパーオブジェクトに変換しません。たとえば、次のコードは true を返します。

new String(“Hello”) instanceof String;

一方、次のコードは false を返します。

“Hello” instanceof String;