我只是在underscore.js中看一下源的一次API,然后在这个方法中使用它徘徊,它似乎什么都不做:
func = null
Run Code Online (Sandbox Code Playgroud)
来源:
_.once = function(func) {
var ran = false, memo;
return function() {
if (ran) return memo;
ran = true;
memo = func.apply(this, arguments);
func = null;
return memo;
};
};
Run Code Online (Sandbox Code Playgroud) 我试图写一个命令来保存与NERDTree兼容的会话,我需要检查NERDTree是否打开,我找不到任何信息,但谷歌.
我发现下面这两个是等价的,但是退出奇怪的是,单个=不是关系运算符而是赋值运算符,为什么它在第二个运算符?
第一:
switch (true)
{
case color == 'green':case color == 'red':case color == 'blue':case color == 'pink':
alert('colorful')
break;
case color == 'black':case color == 'white':
alert('classical')
break;
default:
alert('dull')
break;
}
Run Code Online (Sandbox Code Playgroud)
第二:
switch (color)
{
case color = 'green':case color = 'red':case color = 'blue':case color = 'pink':
alert('colorful')
break;
case color = 'black':case color = 'white':
alert('classical')
break;
default:
alert('dull')
break;
}
Run Code Online (Sandbox Code Playgroud)