请考虑以下事项:
// some_object_name.js
var SomeOtherObject = require('./some_other_object');
var SomeObjectName = _.extend({}, SomeOtherObject);
module.exports = SomeObjectName;
现在考虑以下事项:
// some_other_object.js
var SomeOtherObject = {
method: function() {
console.log('something');
}
}
module.exports = SomeOtherObject;
使用babelify通过browserify运行此操作,然后运行SomeObjectName.method()
,您将获得:
未捕获的TypeError:SomeObjectName.method不是函数
嗯....什么?
如果我理解_.extend
,那么我应该可以访问所有SomeOtherObject
方法