我将如何实现这一点。
var Persistence = new Lawnchair('name');
Object.extend(Lawnchair.prototype, {
UserDefaults: {
setup: function(callback) {
// "save" is a native Lawnchair function that doesnt
//work because
// "this" does not reference "Lawnchair"
// but if I am one level up it does. Say if I defined
// a function called UserDefaults_setup() it would work
// but UserDefaults.setup does not work.
this.save({key: 'key', value: 'value'});
// What is this functions scope?
// How do I access Lawnchairs "this"
}
},
Schedule: {
refresh: function(callback) {
}
}
});
//this get called but doesnt work.
Persistence.UserDefaults.setup();