Convert Object to Hash Object in Mootools?
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 ma开发者_高级运维ke a Hash Object from "animals" and "sounds" arrays?
Doesn't var k = new Hash(u)
work?
精彩评论