javascript oop pattern
TRANSCRIPT
Object-Oriented JavaScript .97�
"6�!� ������+(-�&)����� �.97��#5 �9�8�)�/������� �.97��/�������������%-�!�: �8�)�/���
�������!
!:9-(�+� =/� "�6��
����
.7�#*0�%,
/�L%���
/�D;%��
/�Qbo%���
����������
�����$�����������&4;���
!
(���8����?>'���1��<��
)��
55�����
0�32��������
�
"g�����mj
!var oName = {name : “javascript”, getName : function() {return this.name}};!var oName2 = {name : “c#”, getName : function() {return this.name}};!var oName3 = {name : “original”, getName : function() {return this.name}};!!
���� � ������������
!var oName = {name : “javascript”, getName : function() {return this.name}};!var oName2 = {name : “c#”, getName : function() {return this.name}};!var oName3 = {name : “original”, getName : function() {return this.name}};!!
���� � �������������<�uV�
1]p�),Z�rJ����������&I�FH
function Name(name) {! this.name = name;
this.getName = function() {! return this.name;! };
this.setName = function(newName) {! this.name = newName;! };!}!!!var obj = new Name("javascript");!obj.getName();!!var obj = new Name(“C#”);!obj.getName();
���FH^�mj����������� �����
function Name(name) {! this.name = name;
this.getName = function() {! return this.name;! };
this.setName = function(newName) {! this.name = newName;! };!}!!!var obj = new Name("javascript");!obj.getName();!!var obj2 = new Name(“C#”);!obj2.getName();!!obj.getName === obj2.getName; //false
���FH^�mj����������� �����
1]p�),Z�rJ�����������
&I�FH
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!obj.getName();!!var obj2 = new Name(“C#”);!obj2.getName();!
���������!���mj�
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!obj.getName();!!var obj2 = new Name(“C#”);!obj2.getName();!obj.getName === obj2.getName; //true
���������!���mj�
`EV�",o09�1_�r
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!debugger;!obj.getName();!!var obj2 = new Name("C#");!obj2.getName();!
���������!���mj�
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!debugger;!obj.getName();!!var obj2 = new Name("C#");!obj2.getName();!
���������!���mj�
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!debugger;!obj.getName();!!var obj2 = new Name("C#");!obj2.getName();!
���������!���mj�
obj.__proto__
\MjM*BT����������6+�IHT�������!��cA<�-P�2�
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!debugger;!obj.getName();!!var obj2 = new Name("C#");!obj2.getName();!
���������!���mj�
obj.__proto__ == Name.prototype
?
\MjM*BT����������6+�IHT�������!��cA<�-P�2�
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!debugger;!obj.getName();!!var obj2 = new Name("C#");!obj2.getName();!
���������!���mj�
obj.constructor === Name//true
$hZ�FH^<�R'�OY4
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!debugger;!obj.getName();!!var obj2 = new Name("C#");!obj2.getName();!
���������!���mj�
obj instanceof Name //true
$h"�lc�i7MZ�\MjM�\g�t\
function Name(name) {! this.name = name;!}!!Name.prototype.getName = function() {! return this.name;!};
Name.prototype.setName = function(newName) {! this.name = newName;!};!!!!var obj = new Name("javascript");!debugger;!obj.getName();!!var obj2 = new Name("C#");!obj2.getName();!
���������!���mj�
obj instanceof Name //true !obj instanceof Object //true. // 상속받은 생성자도 true로 나옴
$h"�lc�i7MZ�\MjM�\g�t\
var nameModel = {};!!!var nameController = {! getName : function() {! return this.name;! },! setName : function(newName) {! this.name = newName;! }!}!!!nameController.setName.call(nameModel,"javascript");!nameController.getName.call(nameModel);!
�����������!�$h�?\3�
var nameModel = {};!!var nameController = {! getName : function() {! return this.name;! },! setName : function(newName) {! this.name = newName;! }!}!!nameController.setName.call(nameModel,"javascript");!nameController.getName.call(nameModel);!!var nameModel2 = {};!nameController.setName.call(nameModel2, "java");!nameController.getName.call(nameModel2);
�����������!�$h�?\3�
�������1�3�
,$���)47����[W0���2*'0��
Kd�������������T�.sG�RPA'�P7�*VY�c=sG�������T������o)�!�� ���#�$����� ���&.� %���'��)*$���� �+���-�!+,���(�."
Kd���^N[�S5�n8ek<�qg�(ha\�QY�'>o'�&vU:�o)���#@[�?8�",p�JfX8�fCo)��