标签:
<script type="text/javascript">
/*return的影响
仍然实例化一个对象,不过return后边的代码不给执行
*/
function Animal(){
this.name = "kitty";
this.age = 6;
return 100;
this.run = function(){
console.log(‘在跑步‘);
}
}
//Animal内部有return,cat接收的是对象还是返回信息100。
var cat = new Animal();
console.log(cat);//Animal { name="kitty", age=6}
//cat.run();报错
</script>
标签:
原文地址:http://www.cnblogs.com/yexiangwang/p/4974712.html