If i have a certain object say:
*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?
Problem courtesy of: Itzik984
You’ve omitted part of your source, but what you have looks fine if I fill in the blanks:
Something needs to call
object1 at some point, e.g.:
…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
func symbol defined in the scope where you're using it. You'd have to do something like the first code block above.
Solution courtesy of: T.J. Crowder