简单教程
提交运行
代码编辑器:
<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; } } var my = new person("Sally","Rally",48,"green"); my.changeName("Doe"); document.write(my.lastname); </script>
运行结果: