How can I reference an exported function inside a Node.js module like:
'use strict';
const orm = require('orm');
module.exports = orm.createModel('Accounts');
const Project = require('./Project.js');
// this should be the result of orm.createModel('Accounts')
this.hasMany(Project, 'projects');
However, my linter is complaining about possible strict violation
. Is there a way to do this without defining a variable?
When using jshint/jslint, in strict mode, 'this' that not inside a constructor function will cause 'possible strict violation'.
Try the code below, and you will find that only thrid console.log(this)
don't cause 'possible strict violation'.
'use strict';
console.log(this);
function test() {
console.log(this);
}
function Test() {
console.log(this);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.