Beefy Boxes and Bandwidth Generously Provided by pair Networks
"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??


in reply to OT: Converting some js to Perl

My guess: Either ...

  • we don't see enough code
  • or the programmer was cargo culting
  • or the code is generated.

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
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: OT: Converting some JS to Perl (Hoisting)
by BrowserUk (Patriarch) on Feb 22, 2018 at 19:22 UTC
    or the code is generated.

    That seems to be the case. It uses/is generated by GWT; which appears to generate obfuscated js client code from Java.

    None the less, I've managed to extract the calculation code I was after.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1209749]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-23 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found