问题:
我试图在javascript中找出一个人创建变量然后将其设置为函数的方法。你不能只创建一个名为main()的函数。
function main() {
//....code here
}
代码:
var main = function () {
var now = Date.now();
var delta = now - then;
update(delta / 1000);
render();
then = now;
// Request to do this again ASAP
requestAnimationFrame(main);
};*/
代码在这里,我不确定为什么它被包含在(...代码在这里......)
(function() {
"use strict";
// Doesn't work because strict mode enforces
// the fact that the second example shouldn't work
if (true) {
function fn() {
// This won't run
console.log("doesn't work");
};
fn();
}
})();