Newer Version Available

This content describes an older version of this product. View Latest

Object Types

An attribute can have a type corresponding to an Object.

1<aura:attribute name="data" type="Object" />

For example, you may want to create an attribute of type Object to pass a JavaScript array as an event parameter. In the component event, declare the event parameter using aura:attribute.

1<aura:event type="COMPONENT">
2    <aura:attribute name="arrayAsObject" type="Object" />
3<aura:event>

In JavaScript code, you can set the attribute of type Object.

1// Set the event parameters
2var event = component.getEvent(eventType);
3event.setParams({
4    arrayAsObject:["file1", "file2", "file3"]
5});
6event.fire();

Checking for Types

To determine a variable type, use typeof or a standard JavaScript method instead. The instanceof operator is unreliable due to the potential presence of multiple windows or frames.