"be consistent" | |
PerlMonks |
Re: OT: Converting some JS to Perl (Hoisting)by LanX (Saint) |
on Feb 22, 2018 at 14:13 UTC ( [id://1209749]=note: print w/replies, xml ) | Need Help?? |
My guess: Either ...
JS's way of scoping variables is significantly different to Perl, because of the hoisting of variable declarations in JS, i.e. the scope is the whole surrounding function from start to end, i.e. even prior to var !!! As a consequence there is no block scope like in Perl A usual work around for block scopes is to use a "throw away" anonymous function and to call it right away. This doesn't seem to make sense here, because we don't see any potential conflict or even var declarations (see my first statement) As a side note: there are plans to introduce a let command which works almost the same like my in Perl.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|