Best practices for data objects and global singletons in Cocos Creator

  1. If I want to make a data object in Cocos Creator, that’s not a component, and won’t be attached to the scene, what is the best way to do that? cc.Class({, ES6 class, or standard JavaScript objects using function?

  2. If I want that object to be in a separate JS file (and remember, it’s not a component) what’s the best way to load it?

  3. If I want to make a global singleton, which is not attached to any scene, but holds data relevant to all scenes, what is the best practice for that?

You can simply define a global data like:

window.globalData = {
    foo: 1,
    bar: 'test'
};