When and why must the parenthesis be used after an object and property

Hi, could someone please explain, why they are using a parenthesis here in this code.
ele.style.visibility = (ele.style.visibility == ‘hidden’ ? ‘’ : ‘hidden’);
}, blink_speed);

That’s not valid code. Can you show us where it came from and maybe include the rest of the code? That might allow us to better help.

1 Like

That seems like code to toggle the visibility of an HTML element:

`ele.style.visibility = ((ele.style.visibility == 'hidden') ? 'visible' : 'hidden');`

but I think those parenthesis are not really necessary … I think they do make it easier to read the code.

let visibility = "hidden"; console.log(visibility); visibility = ((visibility == 'hidden') ? 'visible' : 'hidden'); console.log(visibility); visibility = ((visibility == 'hidden') ? 'visible' : 'hidden'); console.log(visibility);

Subjective use of superfluous tokens. Pointless when it comes to readability.

visibility = visibility === 'hidden' ? 'visible' : 'hidden';

Seems pretty readable.