js小问题

myeclipse0123 2009-12-30 03:16:26

function Sing(){
with(arguments.callee);
alert(this.author+":"+this.poem);
};
Sing.author = "李白";
Sing.poem = "汉家秦地";
Sing();
Sing.author = "杜甫";
Sing.poem = "日出汉家天";
Sing();



为什么打印出来是undefined的啊。这个是悟透JavaScript的源代码
...全文
74 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
aellonxie 2009-12-30
  • 打赏
  • 举报
回复
[Quote=引用楼主 myeclipse0123 的回复:]
JScript codefunction Sing(){with(arguments.callee);
alert(this.author+":"+this.poem);
};
Sing.author="李白";
Sing.poem="汉家秦地";
Sing();
Sing.author="杜甫";
Sing.poem="日出汉家天";
Sing();

为什么打印出来是undefined的啊。这个是悟透JavaScript的源代码
[/Quote]


不是this,要么你把对象传进去,要么,直接写对象名,记得实例化
yixianggao 2009-12-30
  • 打赏
  • 举报
回复
看来书中代码没有测试

L@_@K
function Sing(){
with(arguments.callee)
alert(author+":"+poem);
};
Sing.author = "李白";
Sing.poem = "汉家秦地";
Sing();
Sing.author = "杜甫";
Sing.poem = "日出汉家天";
Sing();

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧