Skip to content

Instantly share code, notes, and snippets.

@victorvhpg
Created November 12, 2016 10:00
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 victorvhpg/d4cabb26dc7bfceff849416590149398 to your computer and use it in GitHub Desktop.
Save victorvhpg/d4cabb26dc7bfceff849416590149398 to your computer and use it in GitHub Desktop.
//modulo-teste.js
//exportando variaveis
export var cor = "amarelo";
export let nome = "Pikachu";
export const peso = 20;
// exportando function
export function soma(num1, num2) {
return num1 + num1;
}
// exportando class
export class Pokemon {
constructor(nome, cp) {
this.nome = nome;
this.cp = cp;
}
}
//funcao que não sera exportada, logo não acessível fora do módulo
function subtrai(num1, num2) {
return num1 - num2;
}
//criar uma funcao e depois exporta ela
function algumaCoisa() {
return "alguma coisa";
}
//exportando uma referencia de função
export algumaCoisa;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment