日期:2014-05-16 浏览次数:20399 次
//test.js (function() { var cls = function(){} cls.prototype = { func: function() { alert('func'); }, create: function() { func(); } } cls.prototype.create(); }());
<html> <head> <script src = 'test.js'></script> </head> <body> test </body> </html>
var func = function(){ alert(123) }; (function() { var cls = function(){} cls.prototype = { func: function() { alert('func'); }, create: function() { func(); } } cls.prototype.create(); // 这样调用func的对象是window }());