So I'm starting to use jshint and it gives me a warning at the line with the ternary operator.
crossIconClicked: function (e){
//if W3C_standard ? stopPropagation_for_standard : for_Old_IExplorer
e.stopPropagation ? e.stopPropagation() : (e.cancelBubble=true);
this.shareClickEvent(e);
},
Yes, crossIconClicked
is an event handler
, and e
is the Event
.
The warning is:
Expected an assignment or function call and instead saw an expression (W030)
Why should I refrain from using ternary operator ? What's wrong with the line.
I don't want to supress the warning, just knowing what is the 'danger' here.
Your ternary expression has no left hand side. It is designed to take one of two values and put that value somewhere.
You are using it as a simple if
statement.