是否可以将Node对象从文件返回到另一个文件?
前:
file_1
myObject = function(x){
this.x = x
this.change = function(){
return myObject("new_value");
}
}
module.exports = myObject;
file_2
F1 = require('file_2');
f1 = new F1("some_value");
new = f1.change();
在我的代码中, new 现在有" undefined"。有没有办法返回新对象?
答案 0 :(得分:0)
file_1应为:
myObject = function(x){
this.x = x
this.change = function(){
return myObject("new_value");
}
}
module.exports = myObject;