开发者

Javascript wildcard inside of condition?

I have a basic javascript conditional statement for filtering through some items, it looks like this:

if(item == var_condition) { //do this }

Now what I would like for the var_condition is, if I have a variable condition available than var_condition = my condition, but if I don't have a condition available than var_condition = *, meaning item could equal anything.

Is ther开发者_JAVA百科e a way this can be done? when I try: if(item == "*") it returns no results.

Thank you


Try

if(!var_condition || item == var_condition) {//do this }


you can try:

if(item === (var_condition || item)) { /*do this*/}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜