Skip to content

defaults

defaults(params): DefaultsResult

Defined in: objects/defaults/index.ts:32

Assigns default values from source to target for properties that are undefined or missing. Existing null, 0, "", and false values are preserved — only undefined triggers replacement.

DefaultsParams

The parameters object

DefaultsResult

A new object (inputs are not mutated)

defaults({ target: { a: 1 }, source: { a: 99, b: 2 } });
// => { a: 1, b: 2 }

default values, fill undefined, fallback object, defaults, with defaults

lodash/defaults — semantic reference (https://lodash.com/docs/#defaults)

Error if target is not a plain object

Error if source is not a plain object