JavaSc...unction(3pm)

πŸ“¦
version 0.21 Β· 5 versions
, in ubuntu stonking

✨ NAME ✨

JavaScript::QuickJS::Function β€” it's a JavaScript Function but make it Perl πŸ’–

(also it lives in the User Contributed Perl Documentation section, section 3pm, iykyk)


🌸 SYNOPSIS 🌸

my $func = JavaScript::QuickJS->new()->eval("() => 123");

print $func->();    # prints β€œ123”; note overloading :)

okay bestie look at that last line again. $func->() β€” we're calling a JavaScript function with Perl syntax. that's the overloading. slay πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically this class is the Perl-side glow-up of a JavaScript Function instance.

the MDN link for the real thing is: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function β€” go read it if you want the full lore, we're just the Perl wrapper 🫢

important, no cap: this class is not instantiated directly. you don't new it yourself, it just shows up in your life when QuickJS hands you a function. main character energy but from the backstage ✨

πŸ’– OVERLOADING πŸ’–

for convenience (and because we love you), instances of this class are callable as Perl code references. πŸ”₯

that's literally equivalent to a call() with $this_sv (see below) set to undef. like, same thing, just with less typing.

there's an example up in the SYNOPSIS if you scrolled past it, go look πŸ‘€


πŸ‘‘ INVOCATION METHODS πŸ‘‘

$ret = OBJ->call( $this_sv, @arguments )

does what JavaScript's method of the same name does. say it with me: like JavaScript's method of the same name. periodt. πŸ’œ


πŸŽ€ ACCESSOR METHODS πŸŽ€

each one of these hands you back the matching JS property, no drama:

  • length() β€” returns the corresponding JS property
  • name() β€” returns the corresponding JS property

that's the whole list, bestie, we keep it tight 🌸


and that's the whole page!! this one's from perl v5.42.3, dated 2026-08-19 β€” shoutout to whoever contributed it to the Perl docs, you ate πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from