关于javascript的重载 - Web 开发 / JavaScript
请问这样的话子类不是根据参数列表的不同重载了a方法吗??
但是为什么输出是Child Method count undefined 呢??
不是应该根据参数列表的不同调用了从父类继承的a方法,输出Parent Method count吗??
请指教!~~
function Parent() {
this.a=function(){
alert("Parent Method count");
}}
Children.prototype = new Parent();
function Children() {
this.a = function(cc) {
alert("Child Method count" + cc);
}
}
var c = new Children();
c.a();
JavaScript下没有重载,这样写是把Parent的函数覆盖了。
要重载需要自已做些处理```
因为你写的子类a()方法覆盖父类的a()方法,
只要注释掉子类a()方法就可以了。
this.a=function(){
alert("Parent Method count");
}}
Children.prototype = new Parent();
function Children() {
/*
this.a = function(cc) {
alert("Child Method count" + cc);
}
*/
}
var c = new Children();
c.a();
function Parent() {
this.a=function(){
alert("Parent Method");
}}
Children.prototype = new Parent();
function Children() {
this.b = funct
相关问答:
这是我的文本框
<input type="text" size="60" name="password_answer" id="pwdanswer" value="$!password_answer" >
提交按钮
<input clas ......
最近 使用 js, 经常不能上网, 希望哪位达人 能提供一个
比较完整的 js离线文档,新一点儿,完整点儿的比较好,比如涉及 dom 这些
请指点一二.
万分感谢啊.
http://download.csdn.net/source/566130
......
<html>
<head>
<title>look the status change</title>
</head>
<body>
<script type="text/javascript">
var nowtime ;
var year ;
var month ,da ......
<%
function getName(num)
......
end function
%>
<script>
var num=1;
var xx=<%=getName(num)%>
</script>
如何才能在java ......