961850
.isEmpty(11)当对象为数字是返回为true let _ = require('underscore'); console.log(.isEmpty(11)); /usr/local/bin/node test2.js true 看了源代码
// Is a given array, string, or object empty? // An "empty" object has no enumerable own-properties. .isEmpty = function(obj) { if (obj == null) return true; if (.isArray(obj) || _.isString(obj) || .isArguments(obj)) return obj.length === 0; for (var key in obj) if (.has(obj, key)) return false; return true; };还是不太懂,希望给个建议
最后写个对promise使用的感想 全部操作放进promise用reject返回err,集中处理err,promise的好处