Created
January 27, 2020 18:57
-
-
Save picpoint/159f5c58c5bfcd48302a5b9bbe144396 to your computer and use it in GitHub Desktop.
add classes to commonjs system
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
const calc = require('./calculator.js'); | |
const myCalculator = new calc.myCalc(); | |
console.log(myCalculator.summ(7, 8)); | |
console.log(myCalculator.diff(4, 10)); | |
console.log(myCalculator.divv(4, 5)); | |
console.log(myCalculator.mult(4, 9)); |
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
const superCalc = require('./supercalculator.js'); | |
class Calc extends superCalc.mySuperCalc{ | |
summ(a, b) { | |
return a + b; | |
} | |
diff(a, b) { | |
return a - b; | |
} | |
} | |
exports.myCalc = Calc; |
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
class SuperCalc { | |
mult(a, b) { | |
return a * b; | |
} | |
divv(a, b) { | |
return a / b; | |
} | |
} | |
exports.mySuperCalc = SuperCalc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment