
A collection of Hash methods.
Hash Extras is kept for compatibility reasons. It is expected to be removed with the MooTools 2.0 release. It is encouraged to use Object.Extras instead.
Returns a value of an object by its path.
myHash.getFromPath(path);
#H({ food: { fruits: { apples: "red", lemon: "yellow" } } }).getFromPath("food.fruits.apples"); //returns "red"
Removes values from the Hash.
myHash.cleanValues(method);
$H({ foo: 'bar', something: 'else', missing: null }).cleanValues(); //remove all values < 0 $H({ a: -1, b: 2, c: 0, d: -5 }).cleanValues(function(value){ if ($type(value) != "number") return true; return value > 0; });
Runs all the methods that are values of the hash.
myHash.run()
var myPage = { init: new Hash({ setupNav: function(){ //set up the nav }, setupSearch: function(){ //set up the search } }) }; window.addEvent('domready', myPage.init.run.bind(myPage.init));
© Linux.ria.ua, 2008-2024 |