If i have a certain object say:
function object1(){
function func(){...}
*rest of objec1 content*
...}
exports.func=func; //<---this is wrong (compiler error);
is there a way for me to export func() from outside object1 bounds?
or,within the object1 bounds, and in this case, how to use it from another place?
You’ve omitted part of your source, but what you have looks fine if I fill in the blanks:
Something needs to call
object1at some point, e.g.:or
…in order for the
exports.func = func;line to run, but that’s fine provided you do it.Or did you mean this doesn’t work:
If so, of course not, there’s no
funcsymbol defined in the scope where you’re using it. You’d have to do something like the first code block above.