Whats the ruling for using ternary operators in JavaScript? I couldn’t find a specific ruling in the standards documentation. I saw that the Codidact JS Conventions Documentation referencing bracing uses separate if / else
blocks, instead of utilizing a ternary operator.
I understand that ternary operators could lead to exceeding the line length rule (120), but that can easily be solved, for example:
this.dataset = Object.keys(data).length > 0 ?
data :
{};
(Assuming that data
and {}
are longer lines that would result in exceeding 120 characters).