1

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?

1 Answer 1

2

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

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.