Was sind diese Muster in diesem Backbone TodoMVC-Beispiel

lick in daseispiel für @todomvc-Backbone-Codes. Die Struktur in der js / fold:

├── app.js
├── collections
│   └── todos.js
├── models
│   └── todo.js
├── routers
│   └── router.js
└── views
    ├── app-view.js
    └── todo-view.js

app.js

var app = app || {};
$(function () {
    'use strict';
    // kick things off by creating the `App`
    new app.AppView();
});

collections / todos.js

var app = app || {};

(function () {
    'use strict';
    var Todos = Backbone.Collection.extend({
    model: app.Todo,
    app.todos = new Todos();
})();

models / todo.js

var app = app || {};

(function () {
    'use strict';
    app.Todo = Backbone.Model.extend({
    });
})();

views / app-view.js

var app = app || {};
(function ($) {
    'use strict';
    app.AppView = Backbone.View.extend({
})(jQuery);

Ich habe zwei Fragen

Warumvar app = app || {} in jeder Datei?

Was sind die Unterschiede zwischen$(function(){}), (function(){})(), und(function($))(jQuery)?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage