test-ajax-js
test-ajax-js
by Angelo Rogério Rubin
HTML
<h1>Javascript Módulos e Padrões</h1>
<hr/>
<h3>Padrão IIFE (Immediately-Invoked Function Expression)</h3>
<strong>Código de Exemplo</strong>
<pre>
(function () {
var hideFromOutside = true;
})();
</pre>
<hr/>
<h3>Padrão AMD (Asyncronous Module Definition)</h3>
<strong>Código de Exemplo</strong>
<pre>
define('counter', function () {
var current = 0;
function next() {
return current + 1;
}
function isFirst() {
return current == 0;
}
return {
next: next,
isFirst: isFirst
};
});
</pre>