ㅣ
객체지향이란 단어가 생소하시면 OOP에 대해 공부를 하셔야 합니다.
아래는 예제입니다.
function MyObject(){ this.x = null; this.y = null; this.z = null; } MyObject.prototye.define = function(x, y, z){ this.x = x; this.y = y; this.z = z; }
MyObject.prototye.number_cal = function(){ // do something... }
MyObject.prototye.value_cal= function(){ // do something... }
이렇게 객체를 정의하고 사용할 때는
var o = new MyObject(); o.define(document.getElementById('x').value, document.getElementById('y').value, document.getElementById('z').value);
.....
javascript도 객체지향 처럼 코딩이 가능합니다.
객체지향이란 단어가 생소하시면 OOP에 대해 공부를 하셔야 합니다.
아래는 예제입니다.
function MyObject(){
this.x = null;
this.y = null;
this.z = null;
}
MyObject.prototye.define = function(x, y, z){
this.x = x;
this.y = y;
this.z = z;
}
MyObject.prototye.number_cal = function(){
// do something...
}
MyObject.prototye.value_cal= function(){
// do something...
}
이렇게 객체를 정의하고 사용할 때는
var o = new MyObject();
o.define(document.getElementById('x').value, document.getElementById('y').value, document.getElementById('z').value);
.....