<html>
<body>
<script>
function Dog(a,b,c){
this.name=a;
this.breed=b;
this.age=c;
this.setName=function(cn){this.name=cn}; //새로운 값 셋팅
this.getName=function(){return this.name}; //새로운 값 리턴
}
var dog1=new Dog("뚱돌이","페키니즈",10);
var dog2=new Dog("똘망이","씨추",5);
document.write(dog1.name+","+dog1.breed+","+dog1.age);
document.write("<br>");
document.write(dog2.name+","+dog2.breed+","+dog2.age);
dog1.setName("뚱이");
document.write(dog1.getName()); // 뚱이
</script>
</body>
</html>
'개발하자 > 자바스크립트' 카테고리의 다른 글
event.srcElement (이벤트가 발생한 곳의 주소값) (0) | 2015.02.14 |
---|---|
onmouseover,onmouseout (0) | 2015.02.14 |
원하는 객체의 값 변경(자동차 색상 예제) (0) | 2015.02.14 |
객체생성하기 (0) | 2015.02.14 |
css를 외부파일로 만들어서 사용하기 (0) | 2015.02.14 |