Skip to content

Instantly share code, notes, and snippets.

@lifesinger
Created August 15, 2012 15:23
Show Gist options
  • Save lifesinger/3360992 to your computer and use it in GitHub Desktop.
Save lifesinger/3360992 to your computer and use it in GitHub Desktop.
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
// ==/ClosureCompiler==

function xx() {
function hello(name) {
  alert('Hello, ' + name);
}
eval('(hello("New user"))')
}

把上面这段代码,贴到 http://closure-compiler.appspot.com/home 的左边,然后点击 Compile,会得到:

function xx(){eval('(hello("New user"))')};

Google Closure Compiler 不会考虑 eval 的作用域。 具体可参考:https://developers.google.com/closure/compiler/docs/limitations

不过 Wind.js 中,传给 eval 的字符串是动态生成的,因此应该没问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment