defaults
defaults(target, [ ... sources])
Mimics _.defaults. Assigns first level properties in sources from left to right if they are not already defined.
var defaults = require("can-util/js/defaults/defaults");
var obj = {a: 1, b: 2};
var src = {b: 3, c: 3};
assign(obj, src, {a: 2, d: 4});
console.log(obj); // -> {a: 1, b: 2, c: 3, d: 4}
Parameters
- target
{Object}
:The destination object. This object's properties will be mutated based on the objects provided as [ ... sources].
- sources
{Object}
:The source objects whose own properties will be applied to
target
.
Returns
{Object}
:
Returns the target
argument.