Forked from thisivan/javascript_prototype_objects.js
Created
June 8, 2011 06:45
Revisions
-
boopathi revised this gist
Jun 25, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ ObjectConstructor.prototype.sayHello = function() { alert(this.message); }; //In this way, you can set multiple functions //Avoids writing ObjectConstructor.prototype everytime while defining a function ObjectContructor.prototype = { -
boopathi revised this gist
Jun 25, 2011 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,10 +9,24 @@ ObjectConstructor.prototype.sayHello = function() { alert(this.message); }; /* //In this way, you can set multiple functions //Avoids writing ObjectConstructor.prototype everytime while defining a function ObjectContructor.prototype = { sayHello: function() { alert(this.message); }, setMessage: function(message) { this.message = message; } }; // Using your Prototype object var object = new ObjectConstructor(); object.sayHello(); var object = new ObjectConstructor('Hello Mexpolk!'); object.sayHello(); object.setMessage("Hello Boopathi"); object.sayHello(); -
IvanTorresEdge renamed this gist
Jan 19, 2010 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
IvanTorresEdge created this gist
Jan 19, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ // Defining constructor function function ObjectConstructor(message) { // TODO: Add your own initialization code here this.message = message || 'Hello Prototype World!'; }; // Defining an instance function ObjectConstructor.prototype.sayHello = function() { alert(this.message); }; // Using your Prototype object var object = new ObjectConstructor(); object.sayHello(); var object = new ObjectConstructor('Hello Mexpolk!'); object.sayHello();