Don't understanding this expression

Good afternoon everyone. I have some problems with the IntersectionObserver API and I am trying to breakdown the problems into small spices. Here is a question regarding to the JavaScript, in the following line of codes, I guess it a kind of if-statement, but I can't convert it into typical if-statement and understand it. Why there is a question mark? What are they doing? Confusing, can someone please point out what's the original face of it? https://github.com/mbarker84/smashing-io-header/blob/master/src/index.js#L67
GitHub
smashing-io-header/index.js at master · mbarker84/smashing-io-header
Contribute to mbarker84/smashing-io-header development by creating an account on GitHub.
2 Replies
CodeNascher
CodeNascher2y ago
it's a ternary operation. translates to
if (direction === "down")
const target = getTargetSection(entry)

else
const target = entry.target
if (direction === "down")
const target = getTargetSection(entry)

else
const target = entry.target
William_O^2
William_O^22y ago
Thank you, I will check the topic about ternary operation