Delphi
| projects: | Home Articles JavaScript Bridge |
|---|---|
| resources: | Bugs Mailing List Source Code Sidebar |
Bridge Classes: TJSArray
This class is not ready for production use, it's still quite young in development. If you can help develop this class we would appreciate it. The problem is that SpiderMonkey's standard array class won't permit third-party code to examine property accesses. There may be a way around it with a standard array class, but in the meantime this is a semi-array class that emulates some of the array functionality.
TJSArray's functionality is now pretty much final. The class is not yet finalized, but
now implements several JavaScript-side methods: Splice, Join, Push,
Pop, and Reverse.
This documentation is not complete.
Properties
- JSObj: PJSObject
Only advanced users should use this property. A developer can use this value when working with the SpiderMonkey API. - Len: Integer
The number of elements in the array. JavaScript arrays have a maximum length of 4,294,967,295. - Value[Idx: Integer]: TJSBase
Use this property to access the elements of your array from Delphi / Kylix.
Methods
- constructor Create(AEngine: TJSEngine; AName: string); overload;
Creates an empty array at the global scope namedAName. - function Add(Value: Integer): TJSInteger; overload;
function Add(const Value: String): TJSString; overload;
function Add(Value: Double): TJSDouble; overload;
procedure Add(Obj: TJSBase); overload;
Adds a new element,Value, to the end of the array. - procedure AddJSValAt(Idx: Integer; val: jsval);
Developers should not use this method. It is used injsintf_bridge.pas. - function GetJSValAt(Idx: Integer): jsval;
Developers should not use this method. It is used injsintf_bridge.pas. - function Join: String;
Returns a string containing all the elements of the array as a comma separated list. - procedure RemoveItemAt(Idx: Integer);
Removes the element at indexIdxfrom the array. - procedure Reverse;
Reverses the order of all the elements in the array. - procedure SetSize(Val: Integer);
Sets the length of the array. Existing elements are preserved, new elements are set to 0 or nil.