Skip to content

Instantly share code, notes, and snippets.

@erandirjunior
Created October 8, 2018 22:44
Show Gist options
  • Save erandirjunior/d23f9ff8c55fb5b833bd1bcc8ed013d1 to your computer and use it in GitHub Desktop.
Save erandirjunior/d23f9ff8c55fb5b833bd1bcc8ed013d1 to your computer and use it in GitHub Desktop.
Usando classes no js
import Calculator from './calculator.js'
let calculator = new Calculator()
console.log(calculator.soma(1,1))
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
}
}
<!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