问题标签 [shorthand-if]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
192 浏览

php - PHP If Shorthand Best Practce

Just a weird PHP question about best practice. Assuming the following function:

I want to assign to a $locale variable, the value returned from this function and, if false, set to a default en_GB one. I discovered 2 option for achieving this goal:

I would like to know which one is more correct and why.

Thanks

0 投票
5 回答
1631 浏览

php - 如果解释的速记?标记运算符

对于模板引擎,我想使用 if 条件的简写。我需要检查一个值是否为 != null 如果为真则打印出一些行。我尝试了什么:

我不知道在后面写什么?

0 投票
1 回答
103 浏览

php - php if/else 速记失败

普通表达式工作正常,速记不行。我在这里错在哪里?

谢谢

0 投票
2 回答
85 浏览

php - 不确定 a 的值是多少

在哪里:

我不确定如何解决。

所以我知道这是一个速记运算符,通常是以下情况:

意义

所以:

这是否使 $a 的价值为真?

0 投票
1 回答
173 浏览

c# - c# 是否有简写“something if (condition);” 陈述?

简单而简短:C# 是否有if类似于 Ruby 的速记语句?

0 投票
2 回答
7046 浏览

javascript - shorthand if/else variable exists

I'm simply running a function which checks if the variable year is set if not then set it new Date().getFullYear().

The error I get:

Uncaught ReferenceError: year is not defined

Why can't I check if year exists and if not set it?