首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

这段js 错在哪里?解决思路

2012-06-15 
这段js 错在哪里?太久没写JS了,但也不至于这么简单的代码也会出错, 实在是想不通错在哪里JScript codefunc

这段js 错在哪里?
太久没写JS了,但也不至于这么简单的代码也会出错, 实在是想不通错在哪里

JScript code
function test(){return test;}test.prototype = {    show : function(f){alert(f)}}(new test()).show('d');


报错的是test.prototype = { 这一行,说缺少函数。

[解决办法]
function test(){return this;}
test.prototype = {
show : function(f){alert(f)}
}
new test().show('d');
[解决办法]
JScript code
function test() {return test;}Function.prototype.show = function(f) { alert(f); }var x  = new test();(new test()).show('d');
[解决办法]
JScript code
function test(){return this;}test.prototype = {    show : function(f){alert(f)}}new test().show('licai1210');
[解决办法]
function test(){}
test.prototype = {
show : function(f){alert(f)}
}
var a = new test();
a.show('d');

这样就好了

热点排行