第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么我按老師的代碼寫,卻沒有輸出相應(yīng)的值,name,age都是undefined呢?求幫助

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>OOP</title>

</head>

<body>

<script type="text/javascript">

function Person(name,age){

this.name = name;

this.age = age;

}

Person.prototype.hi = function(){

document.write('Hi,my name is '+this.name+",I'm "+age+' years old now'+"<br>");

};

Person.prototype.LEGS_NUM = 2;

Person.prototype.ARMS_NUM = 2;

Person.prototype.walk = function(){

document.write(this.name+" is walking..."+"<br>");

};

function Student(name, age, className){

Person.call(this.name,age);

this.className = className;

}

Student.prototype = Object.create(Person.prototype);

Student.prototype.constructor = Student;

Student.prototype.hi = function(){

document.write('Hi,my name is '+this.name+",I'm "+age+' years old now, and from '+this.className+"<br>");

};

Student.prototype.learn = function(subject){

document.write(this.name+' is learning '+subject+' at '+this.className+"<br>");

};

var jack = new Student('Jack',10,'Class 1,Grade 3'+"<br>");

jack.hi();

document.write(jack.LEGS_NUM+"<br>");

jack.walk();

jack.learn('Chinese');

</script>

</body>

</html>


正在回答

1 回答

你有兩個地方錯了,一個地方少了一個逗號,一個地方少了一個this,看圖,改過來過后可以正常顯示。http://img1.sycdn.imooc.com//56fbad920001ab2710400204.jpg

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

小不點fly 提問者

非常感謝!
2016-03-31 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為什么我按老師的代碼寫,卻沒有輸出相應(yīng)的值,name,age都是undefined呢?求幫助

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號