You have fallen into a trap called automatic semicolon insertion. Specifically, there must not be a newline between return
and {
var Tweet = Backbone.Model.extend({
defaults: function() {
return { // !!!
author: '',
status: ''
}; // as a convention, I add ; always here, though not strictly needed.
}
});
Otherwise Javascript considers this being 2 statements:
return;
which just returns the value undefined
, and
{
author: '';
status: '';
}
which is a block compound statement, where there are 2 labels: author:
and status:
, each followed by a no-op string literal expression statement ''
. Adding a ,
after the author: ''
line makes it a syntax error, as a statement cannot end in a comma / the comma cannot be followed by a label.