-
-
Save felquis/3678211 to your computer and use it in GitHub Desktop.
Um teste qualquer..
This file contains 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
;(function () { | |
var Plusplus = function (init) { | |
// Verifica se foi usado new | |
if ( !(this instanceof Plusplus) ) { | |
return new Plusplus(init); | |
} | |
// Minha variável de ouro | |
var number = init || 0; | |
// Return var number | |
this._getNumber_ = function () { | |
return number; | |
} | |
// Incrementa var number; | |
this._plusplus_ = function () { | |
number++; | |
} | |
// end Plusplus | |
} | |
// Return number | |
Plusplus.prototype.getNumber = function() { | |
return this._getNumber_(); | |
}; | |
// Incrementa mais 1 e retorna o number | |
Plusplus.prototype.setNumber = function() { | |
this._plusplus_(); | |
return this._getNumber_(); | |
}; | |
if (!window.Plusplus) { | |
window.Plusplus = Plusplus; | |
} | |
})(); | |
;(function () { | |
var game = Plusplus(10), | |
$a = document.querySelectorAll('#clickme')[0]; | |
$a.addEventListener('click', function (e) { | |
e.preventDefault(); | |
this.innerHTML = 'Click me! '+ game.setNumber(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment