K
K
Kaunov_ivan2015-07-24 11:37:37
backbone.js
Kaunov_ivan, 2015-07-24 11:37:37

Question on a simple example from the backbone documentation?

There are two methods in the primary model:

initialize: function() {
           if(!this.get("title")) {
               this.set({"title":this.defaults.title});
           }
       },
       
toggle: function() {
           this.save({done: !this.get("done")});
       },

Why in one case - title - it is necessary to take it in brackets, and in the second case - done - it is not necessary?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2015-07-24
@k12th

In the first case, there is also no need: it will this.set({title:this.defaults.title});work fine.
Read some basic JS syntax book.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question