add alternative signature to Ox.extend
This commit is contained in:
parent
8c347d9009
commit
f8ab51fa40
1 changed files with 7 additions and 1 deletions
|
@ -4,9 +4,15 @@
|
||||||
Ox.extend <function> Extends an object with one or more other objects
|
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({a: 1}, 'b', 2)
|
||||||
|
{a: 1, b: 2}
|
||||||
@*/
|
@*/
|
||||||
Ox.extend = function(object) {
|
Ox.extend = function(object) {
|
||||||
Ox.forEach(Ox.slice(arguments, 1), function(argument, i) {
|
var args = Ox.slice(arguments, 1);
|
||||||
|
if (args.length == 2 && !Ox.isObject(args[0])) {
|
||||||
|
args = [Ox.makeObject(args)];
|
||||||
|
}
|
||||||
|
Ox.forEach(args, function(argument, i) {
|
||||||
Ox.forEach(argument, function(value, key) {
|
Ox.forEach(argument, function(value, key) {
|
||||||
object[key] = value;
|
object[key] = value;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue