Created
August 21, 2013 00:01
-
-
Save brooks/6288885 to your computer and use it in GitHub Desktop.
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 characters
var Phone = function(phoneNumber) { | |
this.phoneNumber = phoneNumber; | |
}; | |
Phone.prototype = { | |
send: function(recipientPhoneNumber, message) { | |
console.log('sending the text message "'+ message +'" to ' + recipientPhoneNumber) | |
} | |
}; | |
var SmartPhone = function(phoneNumber, phoneEmail) { | |
this.phoneNumber = phoneNumber; | |
this.phoneEmail = phoneEmail; | |
}; | |
SmartPhone.prototype.oldSend = Phone.prototype.send; | |
SmartPhone.prototype.send = function(recipientPhoneNumberOrEmail, message) { | |
if(typeof recipientPhoneNumberOrEmail === 'number'){ | |
var recipientPhoneNumber = recipientPhoneNumberOrEmail; | |
this.oldSend(recipientPhoneNumber, message); | |
} | |
else { | |
var recipientEmail = recipientPhoneNumberOrEmail; | |
console.log('sending the email message "'+ message +'" to ' + recipientEmail); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment