CoffeeScript字符串比较 [英] CoffeeScript String Comparison
本文介绍了CoffeeScript字符串比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在CoffeeScript中,有一种方法可以简化以下操作:
In CoffeeScript, is there a way to simplify the following:
if(value === "something" || value === "else" || value === "wow"){}
<已尝试:
I've tried:
if value is "something" or "else" or "wow"
但这会产生以下的字面输出:
But this produces the literal output of this:
if(value === "something" || "else" || "wow){}
有没有办法检查字符串是否是CoffeeScript中的多个值之一(OR或AND)?
推荐答案
我想你可能想要
if value in ['something', 'else', 'wow']
这篇关于CoffeeScript字符串比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文