+ Start a Discussion
Ramakrishna Reddy GouniRamakrishna Reddy Gouni 

what logical operator should work in lightning

What logical operator should work in lightning conditions
Khan AnasKhan Anas (Salesforce Developers) 
Hi Ramakrishna,

Greetings to you!

These Logical Operators will work in Lightning components:

1. &&

Returns true if both operands are individually true.
If you have more than two arguments, you can chain multiple && operations.
This syntax is awkward in markup so we recommend the alternative of using the and()function when you have two arguments. For example, and(isEnabled, hasPermission). The and() function only works with two arguments. 

2. ||

Returns true if either operand is individually true.
If you have more than two arguments, you can chain multiple || operations.
You can alternatively use the or() function when you have only two arguments. The or() function only works with two arguments.

3. !

Unary operator. Returns true if the operand is false. This operator should not be confused with the ! delimiter used to start an expression in {!. You can combine the expression delimiter with this negation operator to return the logical negation of a value, for example, {!!true} returns false.

Note: Instead of && you have to use &&

Please refer to the below links which might help you further.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_operators.htm

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_functions.htm

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ramakrishna Reddy GouniRamakrishna Reddy Gouni
When I used more than two conditions third condition condition onwards it is not working....
Ajay K DubediAjay K Dubedi
Hi Ramakrishna,
Following operators can be used in Lightning:
1.Arithmetic Operators
2.Numeric Literals
3.String Operators
4.String Literals
5.Comparison Operators
6.Logical Operators
7.Logical Literals
8.Conditional Operator
Please refer the below link for more information:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_operators.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Ravi Dutt SharmaRavi Dutt Sharma
Ramakrishna,

Are you facing this issue inside aura:if? If yes, then please note that you have only 2 conditions inside an aura:if. There are workarounds available if you want to calculate more than 2 conditions.