简体   繁体   English

是否可以将三元运算符放入开关中? Javascript

[英]is it possible to put a ternary operator inside a switch? Javascript

is it possible to put a ternary operator inside a switch statement?是否可以将三元运算符放在 switch 语句中?

Something like this (which isn't working):像这样的东西(不起作用):

case "streetName" : entries[0][1] ?? entries[0][1] += `, ${value}` : value;

当然,使用一个问号,不要忘记将结果的第二部分分配给某些东西:

case "streetName" : entries[0][1] ? entries[0][1] += `, ${value}` : entries[0][1] = value;

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

相关问题 是否可以在条件(三元)中放置switch语句? - Is it possible to put a switch statement inside of a Conditional (ternary)? javascript变量内的三元运算符 - javascript ternary operator inside variable JavaScript返回和带有var的三元运算符,可能吗? - Javascript return and ternary operator with var, possible? Javascript三元运算符在输入标记中不起作用 - Javascript ternary operator not working inside input tag forEach中的Javascript三元运算符返回未定义 - Javascript ternary operator inside forEach returns undefined 语法错误:ES6 Switch case inside if else ternary Operator - Syntax Error: ES6 Switch case inside If else ternary Operator 除了 switch 和三元运算符之外,typescript 或 javascript 中嵌套 If else 语句的替代方法 - Alternative for nested If else statements in typescript or javascript otherthan switch and ternary operator 在 Javascript 中,可以将三元运算符的 `?` 放在下一行吗? - In Javascript, is it OK to put the ternary operator's `?` on then next line? Javascript 三元运算符:不需要时将什么作为错误选项? - Javascript ternary operator: what to put as the false option when none is required? 输入类型=“文件”内是否可以使用三元运算符 - Is it possible to use ternary operator inside input type=“file”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM