Object Types

An attribute can have a type corresponding to an Object.

<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.

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

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

// Set the event parameters
var event = component.getEvent(eventType);
event.setParams({
    arrayAsObject:["file1", "file2", "file3"]
});
event.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.