简体   繁体   English

使用 javascript 的代码片段中的三元运算符是什么意思?

[英]What does the ternary operator mean in the code snippet using javascript?

Hi i want to understand what the code below does with ternary operator.嗨,我想了解下面的代码对三元运算符的作用。 Right now it is hard to me to decode with ternary operator.现在我很难用三元运算符解码。 could someone help me understand what this code does.有人可以帮我理解这段代码的作用。 thanks.谢谢。

const handleSelection = React.useMemo(
    () =>
        page.map(row => {
            return singleSelect
                ? toggleSingleSelection
                    ? () => toggleSingleSelection(row)
                    : undefined
                : toggleSelection
                ? () => toggleSelection(row)
                : undefined;
            }),
      [toggleSelection]
  );
page.map(row => {
  if(singleSelect && toggleSingleSelection) {
       return () => toggleSingleSelection(row)
  } else if(!singleSelect && toggleSelection) {
       return () => toggleSelection(row)
  }
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM