NAME
JE::Object - JavaScript Array object class
SYNOPSIS
use JE;
use JE::Object::Array;
$j = new JE;
$js_array = new JE::Object::Array $j, 1, 2, 3;
$perl_arrayref = $js_array->value; # returns [1, 2, 3]
$js_array->[1]; # same as $js_array->value->[1]
"$js_array"; # returns "1,2,3"
DESCRIPTION
This module implements JavaScript Array objects.
The @{}
(array ref) operator is overloaded and returns the array that the object uses underneath. (This is subject to change.)
METHODS
See JE::Types for descriptions of most of the methods. Only what is specific to JE::Object::Array is explained here.
- $a = JE::Object::Array->new($global, \@elements)
- $a = JE::Object::Array->new($global, $length)
- $a = JE::Object::Array->new($global, @elements)
-
This creates a new Array object.
If the second argument is an unblessed array ref, the elements of that array become the elements of the new array object.
If there are two arguments and the second is a JE::Number, a new array is created with that number as the length.
Otherwise, all arguments starting from the second one become elements of the new array object.
- $a->value
-
This returns a reference to an array ref. This is the actual array that the object uses internally, so you can modify the Array object by modifying this array. (This is going to change.)