<!DOCTYPE html>
<html>
<head>
<title>JS动态创建匿名函数</title>
</head>
<body>
<script type="text/javascript">
/**
* 动态生成function
* @return {[type]} [description]
*/
function createFunc(){
return Function("console.log(this.name,'动态function');return 'success';");
}
/**
* 创建function
* @type {[type]}
*/
var newFunc = createFunc();
console.log(newFunc);
/**
* 执行function
* @type {String}
*/
var result = newFunc.call({
name:"李四"
});
console.log(result);
</script>
</body>
</html>