Created
January 28, 2015 00:33
-
-
Save bran921007/6d3fee720e5627b0c001 to your computer and use it in GitHub Desktop.
Snippet - Libreria en Javascript
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
//Self-Executing Anonymous Function (Función anónima auto-ejecutable) | |
(function(grupo, $, undefined){ | |
// Propiedad privada | |
var PasswordAdministrator = "adivina"; | |
// Propiedades publicas | |
grupo.Nombre = "Developers Dominicanos"; | |
grupo.CantidadMiembros = 0; | |
// Metodo publico | |
grupo.AgregarMiembro = function (nombre){ | |
grupo.CantidadMiembros = grupo.CantidadMiembros + 1; | |
return "se agrego " + nombre; | |
}; | |
// Metodo privado | |
function tenerPaciencia(quien){ | |
return "Imposible"; | |
}; | |
})(window.grupo = window.grupo || {}, jQuery); | |
//////////// Pruebas //////////// | |
console.log("Agregar: " + grupo.AgregarMiembro('Jose')); | |
console.log("Nombre: " + grupo.Nombre); | |
console.log("Password: " + grupo.PasswordAdministrator); | |
try { | |
// El metodo es privado, por lo cual mostrara un error. | |
console.log("Paciencia: " + grupo.tenerPaciencia('yo')); | |
} catch( e) { | |
console.log(e.message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment