ready
论坛版主
论坛版主
  • UID24
  • 粉丝0
  • 关注0
  • 发帖数433
  • 社区居民
  • 忠实会员
  • 原创写手
阅读:5612回复:0

JavaScript 对象

楼主#
更多 发布于:2018-08-11 20:43
<!DOCTYPE html>
<html>
<body>
<script>
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("Steve","Jobs",56,"green");
myMother.changeName("Ballmer");
document.write(myMother.lastname);

</script>
  
</body>
</html>
结果:
Ballmer
游客


返回顶部