I'm trying to call a method inside another method but I get error "x is not a function". The methods are in very same class. I'm new in node so I don't get its errors at all. My code is :
file app.js :
const express = require("express");
const app = express();
const pkg = require("./app/b.js");
const port = 3001;
pkg("Hi");
app.listen(port, () => console.log("app is running on port " + port));
and my b.js file is like:
class BFile{
y(str){
// some irrelative codes
x(str)
}
x(arg){
// some code
}
}
const obj = new BFile()
module.exports = obj.y
note: I tried to use "this" before calling x method ( like: this.x(str); ) but "this" is undefined