Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note

Desk Phone API features described in this section are deprecated and supported only on the following models: D40, d45, d50, d60, d62, d65, d70

util.forceArray

Description

Returns an array.

Basic Example: 

Code Block
var newArray = util.forceArray(value[, key]);

If called with a single argument of an array, returns the argument forced into an array. Otherwise, returns a new array containing argument.

...

If value (or value[key]) is undefined, returns an empty array.

Parameters

Name

Required

Type

Default

Description

value

Yes

Value to be forced into an array.

key

No

string

If provided, value[key] is forced into an array.

Examples

util.forceArray returns an array

Code Block
var param = 'foo';
util.forceArray(param);

util.forceArray returns an array, takes an object as the first parameter

Code Block
var param = {'foo' : 'bar'};
util.forceArray(param, 'foo');