Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Free Nodelet Hack: Collapse/expand Nodelets individually (JS hashes)

by ikegami (Pope)
on Feb 05, 2007 at 17:52 UTC ( #598367=note: print w/replies, xml ) Need Help??


in reply to Free Nodelet Hack: Collapse/expand Nodelets individually
in thread Free Nodelet freed

That could've been more 'elegant'... but it's a hack. If JavaScript had hashes...

But it does! JavaScript calls them Objects. (Kinda like how objects are usually implemented as hashes in Perl).

// Hash creation and initialization var hash = new Object; var hash = {}; var hash = { foo: "Foo!", bar: "Bar!" }; var hash = { "spaced out": "ok" }; // Setting hash.foo = "Foo!"; // Static key hash["bar"] = "Bar!"; // Dynamic key // Getting alert("hash.foo: " + hash["foo"]); // Dynamic key alert("hash.bar: " + hash.bar); // Static key // Iterating for (var key in hash) { var val = hash[key]; alert("hash." + key + ": " + val); }
  • Comment on Re: Free Nodelet Hack: Collapse/expand Nodelets individually (JS hashes)
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2021-10-19 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (77 votes). Check out past polls.

    Notices?