会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
开发手记
编程
博客园
::
首页
::
博问
::
闪存
::
新随笔
:: :: ::
管理
::
公告
prototype理解
<
script
>
function
aa()
{
this
.x
=
5
;
this
.y
=
6
;
//
内部定义的函数只有实例化后才可以使用
this
.test
=
function
(a)
{
alert(a
+
"
,
"
+
this
.x
+
"
,
"
+
this
.y);
}
}
//
prototype定义的函数未实例化就可以取得指针
aa.prototype.pany
=
function
(a)
{
alert(a
+
"
,
"
+
this
.x);
}
alert(aa.test);
alert(aa.prototype.test);
alert(aa.pany);
alert(aa.prototype.pany);
window[
"
Hello
"
]
=
aa;
aa.prototype[
"
MyAlert
"
]
=
aa.prototype.pany;
var
xx
=
new
Hello();
xx.MyAlert(
"
0
"
);
xx.pany(
"
1
"
);
//
xx.test(
"
2
"
);
</
script
>
posted on
2006-04-27 22:30
Calendar
阅读(
331
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部