关于this的问题.

function person(firstname,lastname,age,eyecolor){
    this.firstname=firstname;
    this.lastname=lastname;
    this.age=age;
    this.eyecolor=eyecolor;
    this.changeName=changeName;
	function changeName(name){
		this.lastname=name;
	}
}
myMother=new person("Sally","Rally",48,"green");
myMother.changeName("Doe");
document.write(myMother.lastname);

下面代码中,如果说this指向调用它的函数,那么下面的this不是指向changeName.

那么changeName.lastname不是undifined么。

	function changeName(name){
		this.lastname=name;
	}


镜花以西映陵东4076133
浏览 1128回答 1
1回答

Caballarii

changeName是被调用的函数,调用它的函数是myMother
打开App,查看更多内容
随时随地看视频慕课网APP