1) What is Backbone.js?
Backbone.js is a JavaScript framework or library. It is a client-side framework which helps in creating single page application in organized manner i.e. structured layout.
2) Backbone.js is written in which language ?
It is written in JavaScript also it has soft dependence on jQuery and hard dependence on UnderscoreJS.
3) Give some history about Backbone.js.
It was released on 13 October,2010 and developed by Jeremy Ashkenas .
4) Enlist the main component of Backbone.js.
- Model
- View
- Controller
- Router
- Event
5) Describe Architecture of Backbone.js?
It follows the MVC Architecture:
- Model - It helps to retrieve code from the server.
- View - It is a HTML representation.
- Controller - It saves and writes JavaScript application with its logic.
6) Describe the condition when can we use Backbone.js?
- When there exist lots of jQuery/JavaScript code then Backbone.js is used to make it simpler and structured.
- We can use when developing single page web-application.
- To develop fast application having cleaner and more maintainable code.
7) Describe Backbone.js Events?
Backbone.js Events are the modules which helps the object to bind and trigger the custom events. These events can be called by desired name of our choice.
8) Enlist the method that can manipulate Backbone.js events.
- On
- Off
- Trigger
- Once
- Listento
- Stoplistening
- Listentoonce
9) Enlist all built-in events in Backbone.js.
- "add"(model, collection, options)
- "remove"(model, collection, options)
- "reset"(collection, options)
- "sort"(collection, options)
- "change"(model, options)
- "change:[attribute]"(model, value, options)
- "destroy"(model, collection, options)
- "request"(model_or_collection, xhr, options)
- "sync"(model_or_collection, resp, options)
- "error"(model_or_collection, resp, options)
10) What is known as "Heart Of JavaScript Application" in Backbone.js?
Models of Backbone.js are the most important part of building Backbone.js Application due to which it is also known as Heart of JavaScript Application.
11) Define Collection in Backbone.js?
Backbone.js collection is described as ordered set of models. It provides loading and saving of new models to the server. A helper function is created which perform aggregation and computation for a list of models.
12) Enlist the files required to setup Backbone.js.
Three files are required:
- jQuery
- Backbone
- Underscore
13) Give the method that can manipulate Backbone.js collection.
- Extend
- Model
- Initialize
- toJSON
- sync
- Add etc.
14) What does Router in Backbone.js do?
It is used for routing client side application and connects them to their respective events and actions. Also, for an AJAX heavy applications it can be used to change the URL fragment of an application in order to provide bookmark-able and sharable URL's.
15) Explain Backbone.js sync?
It is a function in Backbone.js which is called repeatedly. Backbone.js sync read or save a model to the server and also persist the state of the model to the server.
16) Enlist the method that can manipulate Backbone.js sync.
- Backbone.emulateHTTP
- Backbone.emulatejson
- Backbone.AJAX
17) Explain Backbone.js View.
Backbone.js View represents how your data looks like and model’s data to the user. It can be embedded into any JavaScript Template Library.
18) Define the term Modelbinder.
It is a Class in Backbone.js which is used to make the synchronization process of views and model together.
19) Give Configuration option available in Backbone.js .
- InitialCopyDirection
- modelSetOptions
- change Triggers
- boundAttribute
- suppressThrows
- converter
20) Define model.cid?
It is a special property of models, the cid or client id is automatically assigned to all models when they are first created. It works as an Unique Identifier.
21) What is the function of escape ?
It gets the current value of an attribute from the model but returns the HTML-escaped version of a model’s attribute. It is helpful in preventing XSS attacks, if you are interpolating data from the model into HTML.
22) What is the use of setElement ?
setElement is a function which is used when Backbone view has to be applied to a different DOM element.
23) Explain History in Backbone.js.
Backbone.History is used to keep track of the navigation history of different routes. It is also used to match the appropriate route and callbacks to handle events.
24) What is Template?
Template is used for the view. It is the HTML DOM elements for any View.
24) What is Utility?
Backbone.js Utility class define the following two methods:
- Backbone.noConflict: This method returns the Backbone object back to its original value. We can also use a local instance of Backbone by using method Backbone.noConflict().
- Backbone.$: This method allows user to use the particular jquery.
25) What is Converter?
Converter function helps to copy models attribute to a html attribute and vise versa.
26) What is ModelBinder in Backbone.js?
ModelBinder allows to define scope when you create your bindings using jQuery. We can also define scoping with jQuery selectors if the views are complex.
27) What is Memory Leaks in Backbone.js Application?
A memory leak is a gradual loss of available computer memory. It occurs when a program repeatedly fails to return memory it has obtained for temporary use.
28) What is model.attributes ?
The attributes property is the internal hash containing the model’s state, usually a form of the JSON object representing the model data on the server.
29) What is Push State ?
It allow to navigate to URLs without actually needing a page to refresh.
30) Explain Backbone.Model?
A model is a representation of any component use in application. Therefore, a model can be represented as following:
Data + Logic = Model