Created
December 10, 2016 19:11
-
-
Save KinoAR/93fdda968b7bb13db7a9b89935157000 to your computer and use it in GitHub Desktop.
A gist showcasing Object.Assign simple assignment of a function's properties.
This file contains 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
//============================================================================= | |
// 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