Skip to content

Instantly share code, notes, and snippets.

@tildedave
Last active August 29, 2015 14:19
Show Gist options
  • Save tildedave/52f9c9ac12521c99ef38 to your computer and use it in GitHub Desktop.
Save tildedave/52f9c9ac12521c99ef38 to your computer and use it in GitHub Desktop.
use JavaScript::V8;
use JSON;
my $v8context = JavaScript::V8::Context->new();
$v8context->bind(f => JSON::false);
my $res = $v8context->eval('(function() { return (f ? 1 : 0) })()');
print "$res\n";
# returns 1, because JSON::false is bound to the empty object and so truthy
my $res = $v8context->eval('typeof f');
print "$res\n";
# prints 'object', not 'boolean'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment