多么奇怪的语法? [英] What a strange syntax?
本文介绍了多么奇怪的语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现JQuery网站上的代码构造未知。经过一些格式化后,它看起来像:
I've found unknown for me code construction on JQuery site. After some formatting it looks like:
function (a,c) {
c==null && (c=a,a=null);
return arguments.length>0
? this.bind(b,a,c)
: this.trigger(b)
}
该函数的第一行是什么意思?它是任何技巧或标准的JS代码构造吗?
What does the first line of the function mean? Is it any trick or standard JS code construction?
推荐答案
这是一个使用布尔短路评估只做第二次的技巧如果第一个评估为真,则为一半。 Perl通常会这样:
It's a trick that uses boolean short-circuit evaluation to only do the second half if the first evaluates to true. Perl has this commonly:
<something> or die
如果第一个语句失败,程序结束。
where if the first statement failed, the program ends.
读它为
if (c == null) { c = a; a = null; }
这篇关于多么奇怪的语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文