Skip to content

Instantly share code, notes, and snippets.

@alanhoff
Created May 21, 2014 17:14
Show Gist options
  • Select an option

  • Save alanhoff/9f2221be4bf153ea79dc to your computer and use it in GitHub Desktop.

Select an option

Save alanhoff/9f2221be4bf153ea79dc to your computer and use it in GitHub Desktop.
// Definindo uma função no escopo global
global.somar = function(a, b){
return a + b;
};
// Agora em qualquer lugar do seu projeto, dentro do mesmo
// processo, você pode chamar esta função
var total = somar(1 + 2);
console.log(total); // 3
// **********************************
// **** LEMBRANDO QUE ESSA É UMA ****
// **** PRÁTICA NÃO RECOMENDADA ****
// **********************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment