- Loading...
...
String.prototype.trimRight - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimRight
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource
__FILE__ , __LINE__, __DIR__
Current executing script file, line, directory of the script can be accessed by these global (read-only) properties. This is useful in debug/tracing scripts.
| Code Block | ||
|---|---|---|
| ||
print(__FILE__, __LINE__, __DIR__) |
print function
print function prints it's arguments (after converting those to Strings) on standard output
| Code Block | ||
|---|---|---|
| ||
print("hello", "world") |
load function
Loads and evaluates script from a file or a URL or a script object. Examples:
| Code Block | ||
|---|---|---|
| ||
// can load script from files, URLs
load("foo.js"); // loads script from file "foo.js" from current directory
load("http://www.example.com/t.js"); // loads script file from given URL
// loads script from an object's properties.
// Object should have "script" and "name" properties.
// "script" property contains string code of the script.
// "name" property specifies name to be used while reporting errors from script
// This is almost like the standard "eval" except that it associates a name with
// the script string for debugging purpose.
load({ script: "print('hello')", name: "myscript.js"})
// load can also load from pseudo URLs like "nashorn:", "fx:". "nashorn:" pseudo URL scheme
// for nashorn's built-in scripts. "fx:" pseudo URL scheme for JavaFX support scripts
// load nashorn's parser support script - defines 'parse'
// function in global scope
load("nashorn:parser.js");
// load Mozilla compatibility script - which defines global functions
// like importPackage, importClass for rhino compatibility.
load("nashorn:mozilla_compat.js"); |