0

I want to reuse same function defined within the same class but I am getting error self is not defined. Can anyone suggest what is the correct approach to call a function in nodejs module.

Here is my code,

class addresses{
 constructor() {
    super();
    this.plural = 'addresses';
    this.singular = 'address';
}

parseCoordinates(arr) {
   arr.forEach(function (value, index) {
    if (Array.isArray(value)) {
        self.parseCoordinates(value); // Error at this line
    } else if (!isNaN(parseFloat(value))) {
        arr[index] = (+value);
    }
  });
 }
}
module.exports = new addresses();
sridharnetha
  • 2,104
  • 8
  • 35
  • 69

0 Answers0