[Solved] Shorhand for a = (a == val1) ? null : val1;


You could do a = !a && val1 if you dont mind switching between false and val1.

This is based on the behaviour of && operator in javascript: if first operand is true && operator assigns the second operand, else it returns first operand.

Please note: This does make your code more difficult to read. If you want this to make sense to another developer you would have to add a comment explaining what this line does.

2

solved Shorhand for a = (a == val1) ? null : val1;