Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Phone API Reference - Extended - util.defaults

util.defaults

Description

Merges two objects and returns the result. For each key provided, the target object is checked for a corresponding key. If none is found, it will be created with the provided value. Keys in target that are defined will not be overwritten.

Basic Example: 

util.defaults(target, object);

Parameters

Name

Required

Type

Default

Description

target

Yes

object

The target object to be filled with values.

object

Yes

object

The object containing properties to merge into target.

Examples

util.defaults creates an object with properties 'foo' -> 'test', 'bar' -> 999

var target = {'foo' : 'test'};
target = util.defaults(target, {
    'foo' : 'Target already contains property "foo", this property will not be merged',
    'bar' : 999
});

  • No labels