JE::Ob...::Array(3pm)
π JE::Ob...::Array(3pm) β bestie, it's the JavaScript Array era
okay so real talk, this page lives in the User Contributed Perl Documentation collection, and it's your girl JE::Ob...::Array(3pm) β yes the title got cut off in the header, it's giving mysterious π
, but the actual module is JE::Object::Array. come sit with me.
β¨ NAME β¨
JE::Object β it's the JavaScript Array object class, no cap π
π¦ 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"
like. look at her. iconic behavior from start to finish πβ¨
π DESCRIPTION π
This module implements JavaScript Array objects. that's the whole vibe. arrays, but JavaScript-flavored, living rent free in your Perl process π«Ά
The @{} (array ref) operator is overloaded and returns a tied array that you can use to modify the array object itself. the way that it's tied?? obsessed. but heads up bestie:
The limitations and caveats mentioned in "JE::Object/"USING AN OBJECT AS A HASH"" apply here, too. fr fr, go read that section, it's not optional π
πΈ METHODS πΈ
See JE::Types for descriptions of most of the methods β she's the big sister doc, she covers the basics. Only what is specific to JE::Object::Array is explained here. periodt.
$a = JE::Object::Array->new($global_obj, \@elements)$a = JE::Object::Array->new($global_obj, $length)$a = JE::Object::Array->new($global_obj, @elements)
This creates a new Array object. and the way it decides how depends on what you hand her:
- If the second argument is an unblessed array ref, the elements of that array become the elements of the new array object. literally just slide the array ref in and she copies the vibes π
- If there are two arguments and the second is a
JE::Number, a new array is created with that number as the length. so like, an empty array that knows how long it's supposed to be. main character energy π - Otherwise, all arguments starting from the second one become elements of the new array object. so
new JE::Object::Array $j, 1, 2, 3just... becomes[1, 2, 3]. ate. π
$a->value
This returns a reference to an array. but β and this is the important part, don't skip it π β this is a copy of the Array object's internal array. if you want an array through which you can actually modify the object, use @$a. ngl that distinction is the whole game. don't come crying to me when your edits don't stick because you were poking at a copy π
π SEE ALSO π
JEJE::TypesJE::Object
the whole friend group. go say hi π«Ά
lowkey a warning but make it cute: that@{}tied-array thing comes with the exact same limitations and caveats as the hash section over inJE::Object. no surprises, just read it before you get weird with it π
and that's the page, bestie!! π this was perl v5.36.0, dated 2023-08-25, and it's the JE::Ob...::Array(3pm) page β slay, bye, go build an array π¦β¨π
π¦ where this page comes from
- debian trixie: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms