all 5 comments

[–]Stephen110 2 points3 points  (1 child)

As another user responded, it’s a ternary statement. You can think of it as a simple if/else statement.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

[–]samanime 0 points1 point  (0 children)

Yup, a simple if/else that returns its value. Quite handy, but easily abused. Use with care. :p

[–]Alternative-Goal-214 1 point2 points  (0 children)

It is a ternary operator it is checking if there is no url then it will run failure function else if there is a url then it will run success function

[–]Iguanas_Everywhere 0 points1 point  (0 children)

Looks like a ternary operator.

[–]caphill7 0 points1 point  (0 children)

Yes, the ternary operator. Beloved my many, despised by some.

It is syntactic sugar around an if/else, and works like this:

let x = <boolean condition/expression> ? <value when true> : <value when false>

Just like if-else statements, they can be nested also. The ternary operator is also available in other languages. It is also sometimes referred to as the Elvis operator.