Closed GoogleCodeExporter closed 9 years ago
Functions are not global.
in a required file:
function dumps () { ...
in another file:
dumps(x);
causes "ReferenceError: dumps is not defined"
Critical!
Original comment by bienmano...@googlemail.com
on 7 Oct 2009 at 10:03
Required functions are not global. This is a feature, not a bug :) (and v8cgi
differ
from PHP in this one)
In a required module, you explicitely _define_ (via the "exports" variable)
what do
you want to export. Please see http://jshq.org/commonjs/0.1/modules.html for
more infos.
Original comment by ondrej.zara
on 13 Oct 2009 at 7:34
I understand that now... my problem is, there is not enough example-code "to
learn"
it to use it to create web-sites, although i think v8cgi is faster (to work
with) and
has cleaner-syntax as php (and makes more fun at all!)
Another possibility is to declare with var x = this.x (keeto - mykesx? - use
this
method for the jx.raccoon-framework)
Original comment by bienmano...@googlemail.com
on 14 Oct 2009 at 2:10
To emulate PHP behavior, one can use the include() function:
--- mymodule.js ---
exports.func1 = function() {}
exports.func2 = function() {}
--- main code ---
include("mymodule.js");
func1();
Original comment by ondrej.zara
on 14 Oct 2009 at 6:16
Original issue reported on code.google.com by
bienmano...@googlemail.com
on 7 Oct 2009 at 9:09