我正在使用underscore.js来检查列表中的元素是否为真。以下是其对应的coffeescript代码:
uploading = _(@getViews ".file-forms").some (view) ->
view.uploading is true
打印“上传”,而不是返回true或false,得到:
uploading
y
_chain: true
_wrapped: false
__proto__: Object
以下是'underscore'中'some'的定义:http://underscorejs.org/#some。
此外,'getViews'是backbone layoutmanager中的一个函数,在此处定义:https://github.com/tbranyen/backbone.layoutmanager/wiki/Nested-views。
以下是其他可能有助于调试的变量输出:
_(this.getViews(".file-forms"))
y
_chain: true
_wrapped: Array[1]
0: d
length: 1
__proto__: Array[0]
__proto__: Object
_
function (a){if(a instanceof y)return a;if(this instanceof y)this._wrapped=a;else return new y(a)}
value()
的情况下调用了chain()
。 - PlynxgetViews
和环境中字面上的_
的结果吗? - Plynx