tutorial: http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/ I am going through the CloudEdit rails/backbone.js tutrorial and got stuck on the very first chunk of code. here it is:
var Document = Backbone.Model.extend({
url : function() {
var base = documents ;
if (this.isNew()) return base;
return base + (base.charAt(base.length - 1) == / ? : / ) + this.id;
}
});
我所努力的路线是:
return base + (base.charAt(base.length - 1) == / ? : / ) + this.id;
Since base = documents
isn t base.charAt(base.length - 1) = s
?
I know what it is supposed to do, I am just wondering why it does it. Does the value of base change to documents/
sometimes? Why not just write return base+ / +this.id