Just made the switch over to ES6, running io.js.
I'm writing some class code, but I'm having an unexpected error.
'use strict';
var _ = require('lodash');
class Country {
constructor(blocked) {
this.blocked = ['USA'];
}
ok(input) {
console.log('Receiving...',input['country']);
console.log('Blocked:', this.blocked);
if(_.includes('USA', input['country'])) {
return -1;
}
return 0;
}
}
module.exports = Country;
For whatever reason, everything works well except for the this.blocked
class variable.
When I console log it, it shows up as Blocked: undefined
.
Any thoughts as to what's going on here?
Addition
I'm calling the function in another class as follows...
var Country = require('./filters/country.js');
var country = new Country();
class FilterClassifier {
constructor() {
var self = this;
self.filters = [country.ok];
}
userFilter(params) {
var self = this;
var input = {
country : params.country,
};
console.log(self.filters[0](input));
}
}
module.exports = FilterClassifier;