Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. function TheObject(first, last) {
  2. this.first = first;
  3. this.last = last;
  4. }
  5.  
  6. TheObject.prototype.theMethod = function() {
  7. document.write("first : " + this.first + ", last : " + this.last + "</br>");
  8. };
  9.  
  10. var anObject = new TheObject("Google", "Good");
  11. anObject.theMethod();
  12.  
  13. var TheAnotherObject = function(first, last){
  14. return {
  15. first : first,
  16. last : last,
  17.  
  18. theMethod : function() {
  19. document.write("first : " + this.first + ", last : " + this.last + "</br>");
  20. }
  21. };
  22. }
  23.  
  24. var anotherObject = TheAnotherObject("Yahoo", "Good");
  25. anotherObject.theMethod();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement