2017년 8월 27일 일요일

Object & function

< 함수를 가진 객체 >

함수는 fullName이라는 property의 value로써 정의된다.


<script>
var person = {
    firstName: "John",
    lastName : "Doe",
    id       : 5566,
    fullName : function() {
       return this.firstName + " " + this.lastName;
    }
};
document.getElementById("objectDemo").innerHTML 
    = person.fullName()+"'s id is "+person.id+".";
</script>

댓글 없음:

댓글 쓰기