The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/env perl
use strict;
plan tests => 1;
{
my $js = JavaScript::Writer->new;
my $func = $js->function(
sub {
my $js = shift;
$js->alert("foo");
}
);
is "$func", q{function(){alert("foo");}}
}