JavaScript中的问号

时间:2018-12-18 04:15:15

标签: javascript reactjs

我在github存储库中遇到了这段代码,但我不太理解这小段代码,“?Function”是什么意思?

handleCardNumberBlur = ({ onBlur }: { onBlur?: ?Function } = { onBlur: null }) 
    => (e: SyntheticInputEvent<*>) => {
        const { customTextLabels } = this.props;
        if (!payment.fns.validateCardNumber(e.target.value)) {
            this.setFieldInvalid(customTextLabels.invalidCardNumber || 'Card number is invalid');
        }

        const { cardNumberInputProps } = this.props;
        cardNumberInputProps.onBlur && cardNumberInputProps.onBlur(e);
        onBlur && onBlur(e);
}

所以,请告诉我我是否理解正确,

{ onBlur }: { onBlur?: ?Function } = { onBlur: null }

这意味着onBlur变量(如果已定义)是否保持不变,如果undefined是函数类型并且其值开头为null,则保持不变?

1 个答案:

答案 0 :(得分:0)

那不是Javascript。是Flow