
A collection of Object functions.
Returns a value of an object by its path.
Object.getFromPath(myObject, path);
Object.getFromPath({ food: { fruits: { apples: "red", lemon: "yellow" } } }, 'food.fruits.apples'); // 'red' Object.getFromPath({food: {pizza: 'yum!!'}}, ['food', 'pizza']); // 'yum!!'
Removes values from the object.
Object.cleanValues(myObject, method);
true
the value is kept. Defaults to check if the value != null
.Object.cleanValues({ foo: 'bar', something: 'else', missing: null }); //remove all values < 0 Object.cleanValues({ a: -1, b: 2, c: 0, d: -5 }, function(value){ if (typeOf(value) != "number") return true; return value > 0; });
Deletes a property from the object.
Object.erase(object, key)
var alphabet = {a: 'a', b: 'b', c: 'c'}; Object.erase(alphabet, 'b'); // alphabet == {a: 'a', c: 'c'};
Runs all the methods that are values of the object while passing any additional arguments passed to this function.
Object.run(object[, arg1[, arg2[, ...]]])
var initMyPage = { setupNav: function(){ //set up the nav }, setupSearch: function(){ //set up the search } }; window.addEvent('domready', function(){ Object.run(initMyPage); });
© Linux.ria.ua, 2008-2024 |