我正在尝试使用 node.js,并且我有一组正在导出的方法,module.exports
但是其中一些方法可以用于同一个对象,但我不知道该怎么做。在 PHP 中,我会简单地引用this
. 我知道this
可以在原型对象中引用,但是在 JavaScript 对象表示法中也可以这样做吗?
示例代码:
module.export = {
foo: (a, b) => {
return a + b;
},
bar: () => {
return foo(2, 5); // This is where i run into problems, using 'this' has no effect.
}
}