我是JavaScript的新手。我在這個頁面中發現了以下代碼[https://developer.mozilla.org/en-US/Apps/Quickstart/Building_simple_functionality]。雖然,我知道這些functions
是做什麼的,但是我不清楚_zones
是什麼?有人能詳細解釋嗎?瞬間時區和_zones
import Ember from 'ember';
export default Ember.Controller.extend({
/* create array of timezones with name & offset */
init: function() {
var timezones = [];
for (var i in moment.tz._zones) {
timezones.push({
name: moment.tz._zones[i].name,
offset: moment.tz._zones[i].offset[0]
});
}
this.set('timezones', timezones);
this._super();
},
selectedTimezone: null,
actions: {
/* save a timezone record to our offline datastore */
add: function() {
var timezone = this.store.createRecord('timezone', {
name: this.get('selectedTimezone').name,
offset: this.get('selectedTimezone').offset
});
timezone.save();
},
/* delete a timezone record from our offline datastore */
remove: function(timezone) {
timezone.destroyRecord();
}
}
});
感謝