<body>
<script>
var person=
{
firstname : "John",
lastname : "Doe",
id : 5566,
fullName : function()
{
return this.firstName + " " + this.lastName;
}
};
// 下記二つ書き方の値一緒=Doe
var personLastName1 = person.lastname;
var personLastName2 = person["lastname"];
document.write(personLastName1 + "<br>");
document.write(personLastName2 + "<br>");
document.write("fullNameメソッド()なし:" + person.fullName + "</br>");
document.write("fullNameメソッド()ある:" + person.fullName());
</script>
</body>
上記の結果:
Doe
Doe
fullNameメソッド()なし:function(){return this.firstName + " " + this.lastName;}
fullNameメソッド()ある:John Doe