Symbols > {} (object initializer) |  |

{} (object initializer)

object initializer, curly brackets, braces, {}

Availability

Flash Player 5.

Usage

    object = {name1: value1, name2: value2,...nameN: valueN};

Parameters

`object` The object to create.

`name1,2,...N` The names of the properties.

`value1,2,...N` The corresponding values for each `name` property.

Returns

None.

Description

Operator; creates a new object and initializes it with the specified `name` and `value` property pairs. Using this operator is the same as using the `new Object` syntax and populating the property pairs using the assignment operator. The prototype of the newly created object is generically named the Object object.

Example

The first line of the following code creates an empty object using the object initializer operator; the second line creates a new object using a constructor function.

    object = {};
    object = new Object();

The following example creates an object `account` and initializes the properties `name`, `address`, `city`, `state`, `zip`, and `balance` with accompanying values.

    account = { name: "Betty Skate",
    	address: "123 Main Street",
    	city: "Blossomville",
    	state: "California",
    	zip: "12345",
    	balance: "1000" };

The following example shows how array and object initializers can be nested within each other.

    person = { name: "Gina Vechio",
    	children: [ "Ruby", "Chickie", "Puppa"] };

The following example uses the information in the previous example and produces the same result using constructor functions.

    person = new Person();
    person.name = 'Gina Vechio';
    person.children = new Array();
    person.children[0] = 'Ruby';
    person.children[1] = 'Chickie';
    person.children[2] = 'Puppa';

See also

`[] (array access)`, `new`, Object (object)