0
這是我第一次在JS中創建一個對象。使用JavaScript的對象源錯誤
有人能幫我理解酸味爲什麼不起作用嗎?
這是完整的源代碼:
<script>
function person(firstname,lastname,age,eyecolor) {
this.firstname=firstname;
this.lastname=lastname;
this.age=age;
this.eyecolor=eyecolor;
function getName() {
return this.firstname;
}
}
var myFather = new person("John","Doe",50,"blue");
document.write(myFather.getName());
</script>
謝謝!它的工作=] – user3419680
你可以解釋一下爲什麼? –
@ZaheerAhmed這是一個漫長的故事,但這可能有所幫助:http://stackoverflow.com/a/16063711/1641941 – HMR