add Ox.hasOwn

This commit is contained in:
rolux 2012-05-19 13:39:25 +04:00
parent eab834a643
commit bb6f6d6471

View file

@ -5,8 +5,7 @@ Ox.extend <function> Extends an object with one or more other objects
> Ox.extend({a: 1, b: 1, c: 1}, {b: 2, c: 2}, {c: 3}) > Ox.extend({a: 1, b: 1, c: 1}, {b: 2, c: 2}, {c: 3})
{a: 1, b: 2, c: 3} {a: 1, b: 2, c: 3}
@*/ @*/
Ox.extend = function() { Ox.extend = function(obj) {
var obj = arguments[0];
Ox.forEach(Array.prototype.slice.call(arguments, 1), function(arg, i) { Ox.forEach(Array.prototype.slice.call(arguments, 1), function(arg, i) {
Ox.forEach(arg, function(val, key) { Ox.forEach(arg, function(val, key) {
obj[key] = val; obj[key] = val;
@ -15,6 +14,10 @@ Ox.extend = function() {
return obj; return obj;
}; };
Ox.hasOwn = function(obj, val) {
return Object.prototype.hasOwnProperty.call(obj, val)
};
/*@ /*@
Ox.keyOf <f> Equivalent of [].indexOf for objects Ox.keyOf <f> Equivalent of [].indexOf for objects
> Ox.keyOf({a: 1, b: 2, c: 3}, 1) > Ox.keyOf({a: 1, b: 2, c: 3}, 1)