<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type='text/javascript'>
function x() {}x.prototype.alerts = function() {
alert(this['0']);
};
x["0"] = 'name';
var xx = new x();
xx.alerts();
</script>
</head><body>
</body>
</html>
哪儿有错啊?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type='text/javascript'>
function x() {}x.prototype.alerts = function() {
alert(this['0']);
};
x["0"] = 'name';
var xx = new x();
xx.alerts();
</script>
</head><body>
</body>
</html>
哪儿有错啊?
解决方案 »
- 【请问】大量使用jQuery插件的弊端
- 找寻csdn上的FCKeditor爱好者
- 求Closure: The Definitive Guide这本书的电子版
- 菜鸟请教!
- 从网页导出数据
- SPAN,DIV中加入CONTENTEDITABLE可以编辑其中的文字,但如何判断onChange?象input中一样,捕捉这一事件?
- 我想做一个隔1分钟触发一次网页的按钮动作怎么做?
- cookie的domain怎么设置
- 怎么把iframe周围的边框去掉?
- Js代码在IE下可以调用,在火狐下提示变量为定义!!!求各位大虾看看什么原因!!!
- 用 MVC 的概念来编写前端模块~~~~~~~~~~~ 右键查看源代码!
- 一个JS 刷新问题,图片不居中显示
alert(this['0']);
};this指向实例化后的对象x["0"] = 'name'是给x添加属性,而不是给原型添加属性。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type='text/javascript'>
function x() {}x.prototype.alerts = function() {
alert(this['0']);
};
var xx = new x();
xx["0"] = 'name';xx.alerts();
</script>
</head><body>
</body>
</html>