Created
October 8, 2018 22:44
-
-
Save erandirjunior/d23f9ff8c55fb5b833bd1bcc8ed013d1 to your computer and use it in GitHub Desktop.
Usando classes no js
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
import Calculator from './calculator.js' | |
let calculator = new Calculator() | |
console.log(calculator.soma(1,1)) |
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
export default class Calculator { | |
soma (a, b) { | |
return a + b | |
} | |
diminuicao (a, b) { | |
return a - b | |
} | |
multiplicacao (a, b) { | |
return a * b | |
} | |
divisao (a, b) { | |
return a / b | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>JS</title> | |
</head> | |
<body> | |
<script type="module" src="calc.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment