Differ null and undefined values in Nashorn
I'm running this code ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn"); engine.eval("var out;"); engine.eval("var out1 = null;"); Object m = engine.get("out"); Object m1 = engine.get("out1"); And getting m == null and m1 == null. How to determine if value is undefined or null? Java doesn't have a concept of "undefined", so understanding the distinction will require expressing it in the script's language. I suggest using this expression: Boolean isUndefined = engine.eval("out === undefined"); Actually, the correct way to know if the Object returned by the script is