Skip to content

Instantly share code, notes, and snippets.

@ganeshkbhat
Last active November 30, 2018 08:53
Show Gist options
  • Save ganeshkbhat/c1f5f908c758616cca9a23efcd99c70d to your computer and use it in GitHub Desktop.
Save ganeshkbhat/c1f5f908c758616cca9a23efcd99c70d to your computer and use it in GitHub Desktop.
Object properties Inheritance using prescribed method
function DefaultStrFns(someStr) {
let arr;
this.splitIntoArray = function() {
arr = someStr.split('');
return arr;
}
this.concatFromArray = function() {
return arr.join('');
}
}
function ExtendStrFns(someStr) {
defaultStrFns.call(this, someStr);
this.splitIntoArrayUsingComa = function() {
return someStr.split(',');
}
}
function extendedStringFns(someStr) {
return new ExtendStrFns(someStr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment