乐趣区

TypeError-intermediate-value-is-not-a-function

问题

var date = new Date()
(function(){console.log("anonymous function")
}())

报错:

Uncaught TypeError: (intermediate value) is not a function

解决办法

手动添加逗号

var date = new Date(); //Add ;
(function(){console.log("anonymous function")
}())

原因

JavaScript 的自动添加机制
详情见:https://www.ecma-international.org/ecma-262/5.1/#sec-7.9

退出移动版