1

What is the meaning of :

return i ? null : "red";

? What is the meaning of "?" and ":"

4
  • This question is exactly why we need Google to support symbol-only searches. Commented May 16, 2012 at 11:44
  • @Polynomial: symbolhound.com/?q=%3F+%3A Commented May 16, 2012 at 11:44
  • @DavidHedlund I'm aware of SymbolHound, but most people aren't. We could avoid a lot of questions here if Google would support it. Commented May 16, 2012 at 11:45
  • @Polynomial: true! Although a questions 'googleability' doesn't always correlate with its chances of ending up on SO anyway. Commented May 16, 2012 at 11:47

1 Answer 1

9

That's a ternary operation.

Its syntax is:

condition ? operation-if-true : operation-if-false

For instance

return myVariable >5 ? 'a' : 'b';

return "a" if myVariable is greater than 5, otherwise "b".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.