OPEN between Secret

Java script 에서 객체생성? 본문

java/Java script & jQuery

Java script 에서 객체생성?

해가꿈꾸는달 2014. 7. 28. 15:15
반응형

원래 instance 급은  this.x 이런식인데

자바 스크립트에서는 this.x 로 선언을 하면 에러가 난다.

그냥


<!doctype html>

<html lang="en">

 <head>

  <meta charset="UTF-8">

<script type="text/javascript">

<!--


//객체리터럴

var pobj={

x:100,

y:200,

myShape:'Player',


display:function(){

window.alert(this.myShape+":" + this.x + ","+this.y);

},

moveLeft:function(){

this.x = this.x-1;

this.display()


},

moveRight:function(){

this.x = this.x+1;

this.display()

}


}; 


//객체사용

pobj.display();

pobj.moveLeft();

pobj.moveRight();

//-->

</script>

 </head>

 <body>

  

 </body>

</html>



---------------------------------------------------- 이건 잘 모르겄음

반응형

'java > Java script & jQuery' 카테고리의 다른 글

java script  (0) 2014.07.28
Dom Level2 EventModel  (0) 2014.07.28
여러 객체를 하나의 이벤트로 처리하는방법??  (0) 2014.07.28
Inner Function  (0) 2014.07.28
Java Script 에서 Method's overloading 하기  (0) 2014.07.28