There are several ways to do this. Perhaps the easiest way is to change the scope of the wrap variable. Currently, since it is declared using var inside a function init, it is bound to a function initand is not initdirectly accessible outside . Thus, you can declare "wrap" outside init(this may be a property of the "Example" object):
var Example= {
wrap: 'hello world',
init: function() {
var self = this;
$('a').click(function(){
self.read();
});
},
read: function() {
console.log(this.wrap);
}
};
βExaβmple.init();
'wrap' 'Example' 'Example' , 'Example'.
(Edit: .)