While building an app, I came across this code...
sortOrder = sortOrder === "asc" ? "desc" : "asc";
This is a bit repetitive and gets larger respective to the variable's name.
My idea is to have a kind of ternary assignment operator that looks something like this...
[variable] ?[comparison-operator] [expression1]: [expression2];
sortOrder ?=== "asc": "desc";
asc this would make it
desc, if it's not it would make it
?=== // Ternary Strict Equality Assigner ?== // Ternary Equality Assigner ?!== // Ternary Strict Inequality Assigner ?!= // Ternary Inequality Assigner ?> // Ternary Greater Than Assigner ?>= // Ternary Greater Than or Equal To Assigner ?< // Ternary Less Than Assigner ?<= // Ternary Less Than or Equal To Assigner
Personally, I don't like this syntax so I'll look forward to your ideas :)