views:

133

answers:

1

Hello!

Is it possible to convert/reassemble the Object to Hash Object?

For example and firstly, i have two arrays:

...
var animals=[]; //... "cat","dog","cow"
var sounds=[];  //.. "meow!","woof!","moo!"

var u = animals.associate(sounds); // now "u" is an Object with associative values:

"cat" : "meow!"
"dog" : "woof!"
"cow" : "moo!";

Next, what i want to convert u Object to Hash Object like that in result:

var k = new Hash({cat: "meow!", dog: "woof!", cow: "moo!"});

Is it possible and is it worth? The way i want it, cause i want to use that all priveleges with hash manipulating (for exmpl., "keyOf", "has" methods) that hash objects have in Mootools while, as I know, simple Objs does not. Or can I simply make a Hash Object from "animals" and "sounds" arrays?

+2  A: 

Doesn't var k = new Hash(u) work?

adamse
wow. i'm so dumb. thank u!
moogeek