BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
I'm converting some js, and have come across numerous examples of this construct:
I can convert that to:if(function(){return a.indexOf(Lb)!=-1 }())return Mb;
if( sub{ return index( $a, $lb ) != -1 }->() ) return $Mb;
But this achieves the same thing (in Perl):
if( index( $a, $lb ) != -1 ) return $Mb;
The question(aimed at js progs): Is there anything inherent in the js code that my second Perl versions misses?
Or is this just a case of someone defining an inString() function, that then got inlined, but not unwrapped?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: OT: Converting some JS to Perl (Hoisting)
by LanX (Saint) on Feb 22, 2018 at 14:13 UTC | |
by BrowserUk (Patriarch) on Feb 22, 2018 at 19:22 UTC | |
Re: OT: Converting some js to Perl
by Anonymous Monk on Feb 22, 2018 at 13:14 UTC | |
by LanX (Saint) on Feb 22, 2018 at 14:30 UTC | |
by Anonymous Monk on Feb 22, 2018 at 14:51 UTC | |
by LanX (Saint) on Feb 22, 2018 at 16:13 UTC | |
by Anonymous Monk on Feb 22, 2018 at 21:25 UTC | |
by gsiems (Deacon) on Feb 22, 2018 at 14:54 UTC | |
Re: OT: Converting some js to Perl
by Anonymous Monk on Feb 27, 2018 at 16:54 UTC | |
by BrowserUk (Patriarch) on Feb 27, 2018 at 22:41 UTC | |
by Your Mother (Archbishop) on Feb 27, 2018 at 19:05 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. | |
A reply falls below the community's threshold of quality. You may see it by logging in. |