4
A
回答
8
2
如果你看看它的來源,你會發現這兩個是相同的,_.find實際上調用_.some。
_.find = _.detect = function(obj, iterator, context) {
var result;
any(obj, function(value, index, list) {
if (iterator.call(context, value, index, list)) {
result = value;
return true;
}
});
return result;
};
var any = _.some = _.any = function(obj, iterator, context) {
iterator || (iterator = _.identity);
var result = false;
if (obj == null) return result;
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
each(obj, function(value, index, list) {
if (result || (result = iterator.call(context, value, index, list))) return breaker;
});
return !!result;
};
相關問題
- 1. _.find從underscorejs到JQuery
- 2. Application.Match vs Find
- 3. find -exec basename {} vs find -exec echo $(basename {})
- 4. PouchDB:.query()vs .find()vs .allDocs(),性能?
- 5. jQuery的:«孩子»VS«.find»+«.live»
- 6. MongoDB {aggregation $ match} vs {find}速度
- 7. backbonejs with underscorejs
- 8. 角underscorejs _find子對象
- 9. 地圖使用Underscorejs
- 10. find - mtime vs mmin - 奇怪的結果
- 11. jQuery的單個選擇VS .find()
- 12. echo -n $「some string」different then echo -n「some string」
- 13. Underscorejs「發現」工作不正常
- 14. PHP count some rows
- 15. Hibernate code..some confusion
- 16. 如何將some-sub-domain.some-domain.com中的網址重寫爲some-domain.com/some-sub-domain
- 17. PHP等價於UnderscoreJS每個
- 18. Underscorejs和gettext名稱衝突
- 19. 骨幹underscorejs增值模板
- 20. 如何聯盟/使用UnderscoreJS
- 21. mod_rewrite +「pages/123/some-text」 - >「showpage.php?index = 123&title = some-text」
- 22. Perl中的新Some :: Class和Some :: Class-> new()有什麼區別?
- 23. .is(「:visible」)find
- 24. Ember-Data .find()vs .all() - 如何控制緩存?
- 25. android:youtube player crashing for some videos
- 26. Eval for array with some conditional
- 27. 「@ {some expression;}是什麼意思?
- 28. 如何異步使用_.some
- 29. findFiles by where file name = some name?
- 30. $(this).find不起作用
另一個微妙的區別是,'some'將使用本地實現如果有的話,我不知道的情況也是如此'find' – 2013-03-27 17:56:04