in reply to WWW::Mechanize::Chrome : how to terminate JS code in eval() and return? (OT JS)
principally you are looking for "goto" like constructs.
AFAIK those are in JS
IMHO your function solution is the canonical approach, I'd just prefer an anonymous function to avoid potential conflicts with another "xxx".
(function (){if(1){console.log("aaa"); return;} console.log("bbb");})( +);
(function(){...})() is analogous to sub {...}->() in Perl.
If you are worried about the boilerplate, use Perl to wrap the (function(){...})() part around it and extend the class with a new method.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: WWW::Mechanize::Chrome : how to terminate JS code in eval() and return? (OT JS)
by bliako (Abbot) on Apr 12, 2019 at 12:38 UTC |