Operating environment
Due to historical reasons, cc
is an identifier reserved for Cocos Creator. Its behavior is equivalent to having defined an object named cc
at the top of any module. Therefore, developers should not use cc
as the name of any global object. Example:
/* const cc = {}; // Every Cocos Creator script is equivalent to an implicit definition here */
import * as modules from 'cc'; // Error: Namespace import name cc is reserved by Cocos Creator
console.log(cc.x); // Error: The global object name cc is reserved by Cocos Creator
function f () {
console.log(cc.x); // Correct: cc can be used as the name of a local object
const o = { cc: 0 };
console.log(o.cc); // Correct: cc can be used as a property name
}