sitelink4 http://1 
extra_vars4 ko 
extra_vars5 http://www.taeyo.net/Forum/Content.aspx?SEQ=21743&TBL=JSCRIPT&PGN=1 
extra_vars6 sitelink1 
1. 첫번째 질문

  1. /*부모클래스*/     
  2. function NxControl(containerElement) {   
  3.    this.GetText=function()  {   
  4.       return "부모입니다.";   
  5.   }   
  6. }   
  7.   
  8. /*----------------------------------------------------------------*/
    /*NxControl을 상속받은 자식 클래스*/  
  9. function NxViewer(containerElement) {   
  10.    NxControl.apply(this, arguments);   
  11.    this.GetText=function()  {   
  12.      return "자식입니다.";   
  13.    }   
  14. }   
  15. NxViewer.prototype = new NxControl();   
  16. /*----------------------------------------------------------------*/  
위와 같은데요.
NxViewer 에서 NxControl 의 GetText()를 호출하고 싶습니다.

·미리보기 | 소스복사·
  1. NxViewer.prototype = new NxControl();   
  2. NxViewer.prototype.constructor = NxViewer;  
상속은 위와 같이 합니다.
흔히들 두번째, 생성자를 재지정하는 걸 놓지는데 반드시 생성자를 재지정 해야 합니다.
만약 재지정하지 않을 경우 var o = new NxViewer() 와 같이 생성한 객체가 가르키는 constructor가 부모 생성자가 되어버리는 문제가 생깁니다.
이렇게 하였을 경우 부모의 GetText()를 호출 하는 방법은 아래와 같습니다.
·미리보기 | 소스복사·
  1. var o = new NxViewer();   
  2. alert(o.constructor.prototype.GetText());  
프로토타입 체인을 이해하시면 될거 같습니다.


2. 두번째 다시 질문

답변 감사합니다.
아래와 같이 코딩했더니

·미리보기 | 소스복사·
  1. /*부모클래스*/    
  2.  function NxControl(containerElement)   
  3. {      
  4.     this.GetText=function()     
  5.    {         
  6.       alert( "부모입니다.");     
  7.    }   
  8. }   
  9. /*----------------------------------------------------------------*/  
  10. /*NxControl을 상속받은 자식 클래스*/  
  11. function NxViewer(containerElement)   
  12. {      
  13.     NxControl.apply(this, arguments);      
  14.     this.GetText=function()     
  15.    {        
  16.        alert( this.constructor.prototype.GetText() );   
  17.    }   
  18. }   
  19. NxViewer.prototype = new NxControl();   
  20. NxViewer.prototype.constructor = NxViewer;   
  21. var ctl = new NxViewer();   
  22. ctl.GetText();  

"부모입니다" 가 찍히긴 하는데요. 연이어 'undefined' 앨럿창도 떠버리네요.
'undefined' 가 안뜨게 할 수 있는 방법이 있을까요? ^^

리턴값이 존재 하지 않아서 뜨는 문제 입니다.
아래 참고 하세용.
·미리보기 | 소스복사·
  1. /*부모클래스*/    
  2.  function NxControl(containerElement)   
  3. {      
  4.     this.GetText=function()     
  5.    {         
  6.       //alert( "부모입니다.");     
  7.      return "부모값";  
  8.    }   
  9. }   
  10. /*----------------------------------------------------------------*/  
  11. /*NxControl을 상속받은 자식 클래스*/  
  12. function NxViewer(containerElement)   
  13. {      
  14.     NxControl.apply(this, arguments);      
  15.     this.GetText=function()     
  16.    {        
  17.        alert( this.constructor.prototype.GetText() );   
  18.    }   
  19. }   
  20. NxViewer.prototype = new NxControl();   
  21. NxViewer.prototype.constructor = NxViewer;
    var ctl = new NxViewer();   
  22. ctl.GetText();  
... 음
번호 제목 글쓴이 날짜 조회 수
246 [Gemini] ajax 와 fetch 의 차이 황제낙엽 2025.01.04 3419
245 [검토 완료] 디바이스 카메라로 촬영한 사진을 서버에 업로드하기 샘플 황제낙엽 2024.11.21 3987
244 브라우저에서 이미지를 편집(crop 등) 할 수 있는 오픈소스 Cropper.js 황제낙엽 2024.11.16 3842
243 [ChatGPT] json data 의 정렬 [1] 황제낙엽 2024.07.23 3352
242 DOMContentLoaded 이벤트와 window.onload 이벤트 황제낙엽 2024.07.15 3669
241 fetch() 사용 예제들 황제낙엽 2024.07.09 3380
240 [Copilot] Vanilla JavaScript에서 외부 스크립트 파일에 정의된 함수들을 로드 황제낙엽 2024.06.21 3758
239 [Copilot] ES6 모듈(module) 문법 황제낙엽 2024.06.21 3805
238 [Copilot] JSON 객체 내부 데이터를 순회하면서 조회하는 코드 황제낙엽 2024.06.02 3270
237 [Copilot] JavaScript로 서버에 특정 값을 POST 방식으로 전달하고 응답을 기다리지 않고 바로 종료 황제낙엽 2024.05.31 3615
236 json 데이터 내의 변수명에 prefix 로 type 표현하기 황제낙엽 2024.04.15 3361
235 fetch() 함수 사용 예제 file 황제낙엽 2023.11.23 3605
234 현재 document 의 host 와 port 를 얻는 방법 황제낙엽 2023.10.03 4209
233 (Bard) FileReader 로 여러개의 파일을 read 하는 법 file 황제낙엽 2023.08.23 3660
232 How to build a file upload service with vanilla JavaScript file 황제낙엽 2023.08.22 3715
231 (Bard) JavaScript로 JSON 배열을 작성하는 방법 황제낙엽 2023.08.21 3672
230 모바일 브라우저에서 file input element 를 이용하여 여러장의 이미지를 서버에 전송하려 할때 [1] 황제낙엽 2023.08.21 3703
229 navigator.mediaDevices 황제낙엽 2023.08.21 3798
228 Barcode Detection API 황제낙엽 2023.08.06 3854
227 정규식을 이용한 이메일 검증 스크립트 file 황제낙엽 2023.06.25 2894