This question already has an answer here:
I was using a jQuery Framework and found code which is in the way below. Now: I understand that there is an IIFE and the return is giving an object containing several JSON/Functions. But I don't understand why the two vars are above the return? Is this some kind of private-member pattern because it cannot be accessed using the generator-variable? What kind of pattern is this? Thanks!!
$(document).ready(function() {
var generator = (function() {
var _eventhandler = function() {
$('#id').keyup(function() {
generator.validate(true);
});
}
var _isAllowed= function() {
return true;
};
return {
config: {
//config data
},
init: function() {
console.log("init generator...");
}
validate: function {
return true;
}
}
}());
generator.init();
});
Aucun commentaire:
Enregistrer un commentaire