[英]How can I create a function in Javascript that inherits properties and methods of another function?
Say I have a function: 说我有一个功能:
function parent() {
var address = "house";
var getAddress = function () {
return address;
}
}
How can I make another function that inherits these things? 我该如何做另一个继承这些东西的功能?
how about below : 下面如何:
function otherFunc()
{
addr = parent();
//other stuff..
}
slight modification in your function to make it as per above usage: 对功能进行细微修改以使其符合上述用法:
function parent() {
var address = "house";
var getAddress = function () {
return address;
}
return address;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.