module.exports or exports .// common.jsfunction sayHello(name) {console.log(Hello ${name}!)}function sayGoodbye(name) {console.log(Goodbye ${name}!)}module.exports.sayHello = sayHelloexports.sayGoodbye = sayGoodbye
window object in browsers and the global object in NodeJS , mini games have a global object called GameGlobal. You can use GameGlobal to pass variables between multiple files.// a.jsGameGlobal.globalData = 1
// b.jsconsole.log(GameGlobal.globalData) // Output "1"
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback