Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • JavaScript 1.7 has block scoped variables. I'm not sure what browsers besides FF 2 and newer support it though.

    <html>
    <head>
    <title>Block Scoped Variables</title>
    <script type="application/javascript;version=1.7">

    function methodName() {
        let (i = 7) {
            document.writeln('start: i is ' + i + '<br>');
            for( var j = 0; j < 10; j++ ) {
                let (i = j * 2) {
                    document.writeln('loop: i is ' + i + '<br>');
                }
            }
            document.writeln('end: i is ' + i + '<br>');
        }
    }
    </script>
    </head>
    <body>
    <p>Testing block scoped variables in JS</p>
    <script type="application/javascript;version=1.7">methodName();</script>
    </body>
    </htm l>

    Output:

    Testing block scoped variables in JS
    start: i is 7
    loop: i is 0
    loop: i is 2
    loop: i is 4
    loop: i is 6
    loop: i is 8
    loop: i is 10
    loop: i is 12
    loop: i is 14
    loop: i is 16
    loop: i is 18
    end: i is 7