Exploring the $A.Util APIs

The following table shows supported Util functions:

Util Class Description  Example Code
addClass (Object elementString newClass)

Adds a CSS class to a component.

var myCmp = component.find("myCmp"); $A.util.addClass(myCmp, "myClass");

getBooleanValue (object val): Boolean Coerces truthy and falsy values into native Booleans.
hasClass (Object elementString className): Boolean

Checks whether the component has the specified CSS class.

//find a component with aura:id="myCmp" in markup var myCmp = component.find("myCmp"); $A.util.hasClass(myCmp, "myClass");
isArray (Object obj): Boolean

Checks whether the specified object is an array.

isEmpty (Object obj): Boolean

Checks whether the object is ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.