废话不多说了,代码如下:var obj = {};
obj.echo = function(){return 'I am the echo method!'}
var extObj = {};
extObj.prototype = obj;
alert(extObj.echo());为什么会报错,extObj不存在方法echo啊?
obj.echo = function(){return 'I am the echo method!'}
var extObj = {};
extObj.prototype = obj;
alert(extObj.echo());为什么会报错,extObj不存在方法echo啊?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>JavaScript</title>
<script type="text/javascript">
var obj = {};
obj.echo = function(){return 'I am the echo method!'}
var extObj = {};
extObj.prototype = obj;
alert(extObj.prototype.echo());
</script>
<body>
</body>