JavaScript 有相当于 的吗? : 操作员?
JavaScript 是否有相当于 的东西? Java 中有 :
运算符吗?
IE:
String s = (isBlah ? "blah" : "not blah");
Does JavaScript have the equivalent of the ? :
operator that you have in Java?
Ie:
String s = (isBlah ? "blah" : "not blah");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,非常接近您所拥有的:
所以对于您的变量:
Mozilla.org 参考文档: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special_Operators/Conditional_Operator
Yes, very close to what you have:
So for your variables:
Mozilla.org Reference Docs: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special_Operators/Conditional_Operator
是的。
https://developer.mozilla.org/en/JavaScript/Reference/Operators /Special_Operators/Conditional_Operator
Yes.
https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special_Operators/Conditional_Operator
是的。
Yup.
完全相同,只是 JavaScript 中不需要括号。
It's exactly the same, except you don't need parentheses in JavaScript.
它称为三元运算符。大多数(所有?)C 风格语言都有它。是的,是用js写的,还有Java、C++、PHP等。
http://en.wikipedia .org/wiki/Ternary_operation
It's called a ternary operator. It is in most (all?) C style languages. Yes, it is in js, as well as Java, C++, PHP, etc.
http://en.wikipedia.org/wiki/Ternary_operation