Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Created December 10, 2016 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/93fdda968b7bb13db7a9b89935157000 to your computer and use it in GitHub Desktop.
Save KinoAR/93fdda968b7bb13db7a9b89935157000 to your computer and use it in GitHub Desktop.
A gist showcasing Object.Assign simple assignment of a function's properties.
//=============================================================================
// Object.Assign 2
//=============================================================================
class Printer {
static printLine() {
console.log('============================================\n');
}
}
Printer.printMessage = function(message) {
console.log(message);
};
function Writer(){
}
Writer.writeMessage = function(message) {
this.printMessage(message);
};
Object.assign(Writer, Printer);
console.log(Writer.printLine); //Undefined
Writer.writeMessage("This is printer's static method."); //This is printer's static method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment