title: Java nashorn compare if a java objects is of a certain java type
body: <p>I am using instanceof but it is currently not working as I expect it. I have a variable I retrieve from my java code inside my script. Let's call this variable myObject which is the instance of a MyObject class, as you would expect.</p>
  
  <pre><code>if (myObject instanceof Java.type("MyObject")) {
      //The check doesn't pass; the code here doesn't execute
  }
  </code></pre>
  
  <p>I could only find vague information on the net about this. What is the definite way of checking if myObject is an instance of the MyObject class as I would easily do in Java?</p>
  
  <p>Thanks!</p>