ShowAll Questionssorted byDate Posted
Ramakrishna Reddy Gouni

# what logical operator should work in lightning

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

Greetings to you!

These Logical Operators will work in Lightning components:

1. &amp;&amp;

Returns true if both operands are individually true.
If you have more than two arguments, you can chain multiple &amp;&amp; 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 &amp;&amp;

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 Gouni
When I used more than two conditions third condition condition onwards it is not working....
Ajay 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