美文网首页
三元运算符?:(mdn自学)

三元运算符?:(mdn自学)

作者: 实肆 | 来源:发表于2019-03-12 19:22 被阅读0次

var condition1 = true,
condition2 = false,
access = condition1 ? (condition2 ? "true true": "true false") : (condition2 ? "false true" : "false false");/因为condition1 = true,返回(condition2 ? "true true": "true false"),condition2 = false返回"true false"/

console.log(access); // 输出 "true false"

相关文章

网友评论

      本文标题:三元运算符?:(mdn自学)

      本文链接:https://www.haomeiwen.com/subject/xofopqtx.html