OO 접근 방식을 Java Script에서 사용할 수 있습니까? JavaScript를 에서 서버 쪽과 클라이언트 쪽 모두 node.j를 사용하여 사용합니다. 현재 쿼리 대신 CRUD 작업에 쿼리를 사용하고 있습니다. DTO의을 사용하여 데이터베이스에 데이터를 저장 하시겠습니까?Java Script에서 객체 지향 접근 방식
3
A
답변
0
예, 프로토 타입 상속을 사용하여 에뮬레이트 할 수 있습니다. 규칙은 언어가 프로토 타입을 기반으로하므로 프로토 타입 체인과 관련하여 약간의 연구가 필요할 것입니다. 그러나 결국에는 매우 유용합니다.
EventEmitter에서 상속받은 Node 코어의 것들을 확인하십시오. 그들은 util.inherits라는 내장 함수를 가지고 있으며,이 함수는 최신 버전의 ECMA를 구현합니다. 그것은 다음과 같습니다
https://github.com/joyent/node/blob/master/lib/stream.js#L22-29 커피 스크립트에서
var events = require('events');
var util = require('util');
function Stream() {
events.EventEmitter.call(this);
}
util.inherits(Stream, events.EventEmitter);
, 수업이 __extends 귀결 코드의 약간 다른 세트로 컴파일 :
/**
* Inherit the prototype methods from one constructor into another.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be rewritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
exports.inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
예제 사용 스트림 클래스입니다 기능. I 이것은 브라우저 간 호환성이 더 높을 것이라고 생각하지만 특히 Object.create를 지원하지 않는 사람을 구체적으로 기억하지 않습니다.
var __hasProp = Object.prototype.hasOwnProperty, __extends =
function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key))
child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
+0
확인 조쉬 내가 시도 할 것이다. – Baskar
관련 문제
- 1. 개체 지향 업데이트 접근 방식
- 2. Google Script에서 객체 지향 프론트 엔드에 대한 해결 방법이 있습니까?
- 3. 접근 방식?
- 4. Eclipse에서 C# SLN 파일 접근 방식 (Java)
- 5. 왜 "기반 접근 방식"이 "절차 접근 방식"보다 낫습니까?
- 6. 객체 지향 프로그래머를위한 스키마
- 7. 데이터베이스 동기화를위한 접근 방식
- 8. 백그라운드 서버 접근 방식
- 9. 코드 검토 접근 방식
- 10. 서비스로서의 소프트웨어 - 접근 방식
- 11. 웹 워크 플로 접근 방식
- 12. 객체 지향 프로그래밍
- 13. 변환 응용 프로그램에 대한 객체 지향 설계 방식
- 14. 일대일 접근 방식 또는 다른 방식?
- 15. 자바에 대한 객체 지향 접근 이해에 도움이 필요합니다.
- 16. 어떤 접근 방식이 객체 지향 프로그래밍 측면에서 더 낫습니까?
- 17. 객체 지향 프로그래머를위한 C
- 18. Java 객체 지향 디자인 : Java에서 다중 객체 반환
- 19. 객체 지향 프로그래밍 : 기본적인 객체 그 이상
- 20. C# 유효성 검사 접근 방식
- 21. CURLing을위한 최상의 RoR 접근 방식
- 22. 서버 연결 처리기 접근 방식
- 23. WinForms MVC 예제 접근 방식
- 24. 기본 키 생성을위한 접근 방식
- 25. 프로그래밍 이해의 다른 접근 방식
- 26. memcached 세션에 대한 접근 방식
- 27. 코어 데이터를위한 다국어 접근 방식
- 28. 배열의 배열에 대한 접근 방식
- 29. 음성 인식 - HMM 접근 방식
- 30. 정규 분포 최상의 접근 방식
더글러스 크록 포드의 * 자바 스크립트를 읽어 보시기 바랍니다 :. 좋은 부품 " – ebohlman
확인 ebohiman 내가 시도 할 것이다 – Baskar