Embedded JavaScript defines a set of global functions, constructors and variables for every JavaScript program.
JavaScript VariablesThe ESP run-time defines the following JavaScript variables for use inside an ESP page.
Variable Name
|
Description
|
false
|
False boolean value
|
global
|
Global variables for this request
|
Infinity
|
Floating point number set to Infinity
|
local
|
Local variables for the outermost JavaScript block in the ESP web page |
Nan
|
Floating point number set to "Not a Number"
|
null
|
Defined variable set to Null
|
true
|
True boolean value
|
undefined
|
Variable has no value and is set to the Undefined Value
|
JavaScript ConstructorsEJS defines the following object constructors.
Script Name
|
Syntax
|
Examples
|
Description
|
Array
|
Array(elt1, elt2, ...)
Array(size)
|
var o = new Array("item 1", "item 2");
var o = new Array(256);
|
Create an array and insert elements. The second form creates an array with elements named "0", "1", "2", and so forth up to the nominated size. |
Object
|
Object();
|
var o = new Object();
|
Create a new object.
|
JavaScript FunctionsEJS defines the following global functions:
Script Name
|
Syntax
|
Examples
|
Description
|
assert
|
assert(condition)
|
|
|
eval
|
eval(script);
|
eval("var " + x + " = " + string); |
Evaluate the given script.
|
exit
|
exit(status)
|
exit(0);
|
Immediately terminate the current script or ESP.
|
include
|
include(filename);
|
include("myLib.js");
|
Server side inclusion of a JavaScript library. The nominated file is read and parsed inline when the page is compiled by AppWeb.
|
print
|
print(string, ...);
|
print("Hello World\n"); |
Print the given strings to the web server standard output. |
println
|
print(string, ...);
|
print("Hello World"); |
Print the given strings to the web server standard output followed by a new line. |
printVars
|
print(v, ...);
|
print(obj1, obj2, obj3);
|
Print the string representation of the given objects to the web server standard output. Objects are expanded and all properties are printed. Great for debugging.
|
refCount
|
refCount(o);
|
var count = refCount(obj);
|
Return the number of references to this object.
|
trace
|
trace(message);
trace(level, message);
|
trace(2, "Message at level 2");
|
Write a message to the AppWeb log.
|
|