function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert_StrunkRobert_Strunk 

Lightning Performance - Ternary IF over Standard IF

I am going through the premiere online course for Lightning Components right now and saw something I was curious about.  

The particular module that I am watching is showing how tag attributes can by dynamically set using expression syntax.  Nothing ground breaking there but what I found interesting was at instead of using a standard IF statement it used a ternary IF statment.  At first I thought it was just a style preference by the developer who wrote the example, but I am also curious if there is some sort of efficiency gain in the lightning framework by doing so.  

Basically he used:
class="{!(v.expenseSum != v.approvedSum ? 'alert-danger' : 'alert-success')}

Instead of:
class="{! IF(v.expenseSum != v.approvedSum , 'alert-danger' , 'alert-success')}

I totally understand they are the exact same thing, but from an efficiency standpoint is there any benefit to doing it this way? 
Best Answer chosen by Robert_Strunk
Mohith Kumar ShrivastavaMohith Kumar Shrivastava
I think the IF function will not work in lightning components as its no where documented in expression guide .

Lightning Expressions are different than that of the VF expressions we are used so far .

Here is documentation of SFDC which explains this .

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_conditional.htm?search_text=IF%20expression

You can use aura:if instead of the normal ternary operation but I believe aura:if is generally slower compared to ternary operations.