您能否在使用严格模式的同时获得全局范围,并确保您可以在非窗口环境中运行。
请参阅以下示例:
define(['other', 'thing'], function() {
// this === window in desktop environment
// this === GLOBAL in node environment
});
define(['other', 'thing'], function() {
"use strict";
// this === undefined in desktop environment
// this === GLOBAL in node environment
// As of my understanding node has to be configured using `node --use_strict`
// (http://stackoverflow.com/questions/9031888/any-way-to-force-strict-mode-in-node)
// But that not the point.
});
有什么办法可以在里面获取全局变量(window
/ GLOBAL
)define
。