Answer the question
In order to leave comments, you need to log in
Why are function properties not visible in nodejs class constructor?
There is a type constructor:
"use strict"; // не влияет на возникновение ошибки
function Make() {
this.aaa = function () {}; // любая функция с именем или без
}
exports.Make = Make; // Экспортирую конструктор
var elem = new Make();
a = require("./Make.js"); // добавляю var -- получаю undefined
b = new a.Make(); // добавляю var -- получаю undefined
Answer the question
In order to leave comments, you need to log in
> var mk=require("./Make.js");
undefined
> var elem = new mk.Make();
undefined
> console.log(typeof elem.aaa);
function
undefined
> elem.aaa();
undefined
.............. ПЕРЕОПРЕДЕЛИЛ: this.aaa = function () { return "OK"; }
> var mk=require("./Make.js");
undefined
> var elem = new mk.Make();
undefined
> console.log(typeof elem.aaa);
function
undefined
> elem.aaa();
'OK'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question