Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Free Nodelet freed

by jZed (Prior)
on Oct 14, 2004 at 17:17 UTC ( #399277=note: print w/replies, xml ) Need Help??


in reply to Free Nodelet freed

Great idea, thanks. The square brackets thing without code tags makes javascript pretty unusable - no way to use square brackets in javascript, so no javascript arrays.

Replies are listed 'Best First'.
Re^2: Free Nodelet freed
by cLive ;-) (Prior) on Oct 14, 2004 at 19:02 UTC
    eval is your friend (using the word friend in its loosest form :)
    <script language="javascript"> var arr = new Array('one','two'); var lb = "\x5B"; var rb = "\x5D" var code = "alert(\"Second element is \"+arr"+lb+"1"+rb+")"; eval(code); </script>

    :)

    cLive ;-)

      This might be simpler:
      // Hack around mangling of left square bracket by PerlMonks. function get_item(a, i) { return eval("a\x5Bi]"); } function set_item(a, i, v) { return eval("a\x5Bi] = v"); }
      Usage:
      var a = new Array(5); set_item(a, 2, "Hello World\n"); alert(get_item(a, 2));

      Update: Never mind. New useful escapes documented here.

Re^2: Free Nodelet freed (JS square brackets)
by tye (Sage) on Oct 14, 2004 at 17:22 UTC

    Code tags wouldn't help. CODE tags just turn [ into &#91; (among other things, of course).

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2021-10-27 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (91 votes). Check out past polls.

    Notices?