JS Lib
Overview
This class provides essential JavaScript constants and utility functions like Infinity, NaN, and undefined, along with URI encoding/decoding (encodeURI, decodeURIComponent) and string parsing (parseFloat, parseInt). It includes utilities like isFinite and isNaN for value validation and supports dynamic code evaluation through eval.
Returned Types
Boolean,String,Date,Number,Array,Function,IterableValue,Iterator,JSON,Map,Math,Namespace,QName,RegExp,Set,[Special Operators](./special operators.md),Statements,XML,XMLList,BigInt,Promise,
Properties Summarized
Methods Summarized
Decodes a URI previously encoded with encodeURI or another similar routine.
Decodes a URI component previously created by encodeURIComponent or by a similar routine.
Encodes a URI component by replacing all special characters with their corresponding UTF-8 escape sequences.
Returns true if the given name can be used as a valid name for an XML element or attribute.
Makes a integer from the starting numbers in a given string in the base specified.
Makes a integer from the starting numbers in a given string in the base specified.
Properties Detailed
Infinity
Numeric value representing infinity.
Type Number
Sample
Infinity
NaN
Value representing Not-a-Number.
Type Number
Sample
NaN
undefined
The value undefined.
Type Object
Sample
undefined
Methods Detailed
decodeURI(encodedURI)
Decodes a URI previously encoded with encodeURI or another similar routine.
Parameters
String encodedURI ;
Returns: String
Sample
var str = "http://www.mysite.com/my code.asp?name=[cool]";
var encoded = encodeURI(str);
var decoded = decodeURI(encoded);
application.output(encoded);//http://www.mysite.com/my%20code.asp?name=%5bcool%5d
application.output(decoded);//http://www.mysite.com/my code.asp?name=[cool]
decodeURIComponent(encodedURI)
Decodes a URI component previously created by encodeURIComponent or by a similar routine.
Parameters
String encodedURI ;
Returns: String
Sample
var str = "my code.asp?name=[cool]";
var encoded = encodeURIComponent(str);
var decoded = decodeURIComponent(encoded);
application.output(encoded); //my%20code.asp%3fname%3d%5bcool%5d
application.output(decoded); //my code.asp?name=[cool]
encodeURI(URI)
Encodes a URI by replacing certain characters with escape sequences.
Parameters
String URI ;
Returns: String
Sample
var str = "http://www.mysite.com/my code.asp?name=[cool]";
var encoded = encodeURI(str);
var decoded = decodeURI(encoded);
application.output(encoded);//http://www.mysite.com/my%20code.asp?name=%5bcool%5d
application.output(decoded);//http://www.mysite.com/my code.asp?name=[cool]
encodeURIComponent(URI)
Encodes a URI component by replacing all special characters with their corresponding UTF-8 escape sequences.
Parameters
String URI ;
Returns: String
Sample
var str = "my code.asp?name=[cool]";
var encoded = encodeURIComponent(str);
var decoded = decodeURIComponent(encoded);
application.output(encoded); //my%20code.asp%3fname%3d%5bcool%5d
application.output(decoded); //my code.asp?name=[cool]
eval(expression)
Evaluates JavaScript code passed as a string. Returns the value returned by the evaluated code.
Parameters
String expression ;
Returns: Object
Sample
eval("var x = 2 + 3;");
application.output(x); // prints: 5.0
isFinite(n)
Returns true if the given number is a finite number.
Parameters
Number n ;
Returns: Boolean
Sample
application.output(isFinite(1)); // prints: true
application.output(isFinite(Infinity)); // prints: false
application.output(isFinite(isNaN)); // prints: false
isNaN(value)
The NaN property indicates that a value is 'Not a Number'.
Parameters
Object value ;
Returns: void
Sample
isNaN( value )
isXMLName(name)
Returns true if the given name can be used as a valid name for an XML element or attribute. This was implemented by the Rhino engine as part of Ecma-357 which was meanwhile withdrawn.
Parameters
String name ;
Returns: Boolean
Sample
application.output(isXMLName("good_name")); // prints: true
application.output(isXMLName("bad name")); // because of the space, prints: false
parseFloat(text)
Makes a floating point number from the starting numbers in a given string.
Parameters
String text ;
Returns: Number
Sample
parseFloat('string')
parseInt(text)
Makes a integer from the starting numbers in a given string in the base specified.
Parameters
String text ;
Returns: Number
Sample
parseInt('0774')
parseInt(text, radix)
Makes a integer from the starting numbers in a given string in the base specified.
Parameters
Returns: Number
Sample
parseInt('0774' , 8)
Last updated
Was this helpful?