Created
May 10, 2021 20:01
-
-
Save djalmajr/07b343bcb589f7c8fbc042d4a182aa05 to your computer and use it in GitHub Desktop.
Medium Post
This file contains hidden or 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
// Exemplo de padrão modular usando IIFE | |
var contador = (function () { | |
var num = 0; | |
return { | |
incrementar: function () { | |
return ++num; | |
}, | |
resetar: function () { | |
return (num = 0); | |
}, | |
}; | |
})(); | |
console.log(contador.incrementar()); // 1 | |
console.log(contador.incrementar()); // 2 | |
console.log(contador.num); // undefined | |
console.log(contador.resetar()); // 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment