Advertisement
Guest User

Untitled

a guest
Nov 10th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Person(first,last){
  2.     var first = '', last = '';
  3.   this.getName = function(){
  4.       return this.first + ' ' + this.last;
  5.   }  
  6.     this.setName = function(first,last){
  7.         this.first = first;
  8.         this.last = last;
  9.     }
  10. };
  11. var person = new Person('John','Smith');
  12. console.log(person);
  13.  
  14. var obj = {
  15.     first: '',
  16.     last: '',
  17.     getName: function(first,last){
  18.        return first + ' ' + last;
  19.     },
  20.     setName: function(first,last){
  21.         this.first = first;
  22.         this.last = last;
  23.     }
  24. }
  25.  
  26. obj.setName('John','Smith');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement