我写了下面的测试代码,我想obj.my().showTxt()
显示“test1”,但是什么也没有显示,我犯了什么错误?谢谢!
<html>
<body>
Primitive and String Objects
<script type="text/javascript">
function Class1() {
this.showTxt = function () { alert(this.name) }
}
Object.prototype.my = Class1;
var obj = new Object();
obj.name = "test1";
obj.my().showTxt();
</script>
</body>
</html>