This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scriptable scope = cx.initStandardObjects(); | |
Object result = cx.evaluateString(scope, "obj = {a:1, b:['x','y']}; arr = [1,2,3]; i = 1; d = 1.2345; b = true; s = 'string'; re=/.*/; f = function() { }; dt = new Date(); n=null; un=undefined; nan=Number.NaN; pinf=Infinity; ninf=-Infinity;", "MySource", 1, null); | |
for (String name: new String[]{"obj", "arr", "i", "d", "b", "s", "n", "un", "re", "f", "dt", "nan", "pinf", "ninf"}) { | |
Object o = scope.get(name, scope); | |
String msg = name + "=" + String.valueOf(o) + " " + (o != null ? o.getClass().getName() : "null"); | |
if (o instanceof Scriptable) { | |
msg += " Scriptable"; | |
} | |
if (o instanceof Function) { |
NewerOlder