Corporate Training
Request Demo
Click me
Menu
Let's Talk
Request Demo

Backbone.js Interview Questions and Answers

by Mohammed, on May 18, 2018 5:53:37 PM

Backbone.js Interview Questions and Answers

Q1. What is Backbone.js ?

Ans: Backbone.js is a client-side (Model, View, Controller) MVC-based JavaScript framework.It purely written in Javascript.
Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

Q2. In which language, backbone JS is writeen?

Ans: javaScript

Q3. What are main components of Backbone Js?

Ans:

  • Model
  • View
  • controller
  • Router
  • Event class object

Q4. What are the three js files that are required to setup a working environment for Backbone.js? 

Ans: You are required following three js files to setup a working environment for Backbone.js

  • jQuery
  • Backbone.js
  • Underscore

Q5. What are the keypoints of Backbone?

Ans: It has hard dependency with underscore.js to make it more functional and supporting.
With jQuery it has a soft dependency.
When the model changes it can update the HTML of your application automatically.
Significantly clean and elegant way for DOM manipulations and UI updates
In your application put these files within js folder and use it in your index.html page.

Q6. What is a collection in Backbone.js?

Ans: In Backbone.js, the collection is used to represent ordered set of models. Any event in model triggers an event in collection directly. For example, you can bind “change” event to be notified in a case when any model in the collection has been modified.

Q7. What is ModelBinder in Backbone.js? 

Ans: The ModelBinder class is used to make synchronization process of views and models together.

Q8. What is Backbone.sync?

Ans: When Backbone wants to save or read a model to the server it calls out a function called as Backbone.sync

Q9. What is the difference between the properties “id” and “cid” on a model object? 

Ans: The “id” property on a model is automatically assigned based on the “id” set in the model’s attributes hash. Ideally, this is the ID that you receive from the rest API for the resource that you are querying. On the other hand, “cid” is an ID temporarily assigned to each model and is useful until an actual ID is determined for the object. For example, a model pushed to a collection that has not yet been persisted can be addressed using “cid”, until it is saved in the database and an actual ID is generated for it.

Q10. List Dependencies of using BackboneJs?

Ans: Backbone’s Js only hard dependency is Underscore.js ( >= 1.8.3). For RESTful persistence and DOM manipulation with Backbone.View, include jQuery ( >= 1.11.0), and json2.js for older Internet Explorer support. (Mimics of the Underscore and jQuery APIs, such as Lodash and Zepto, will also tend to work, with varying degrees of compatibility.)

Q11. List out configuration options available in Backbone Js?

Ans:

  • InitialCopyDirection
  • modelSetOptions
  • change Triggers
  • boundAttribute
  • suppressThrows
  • converter

Q12. What is a converter in Backbone Js ?

Ans: When a model’s attribute is copied to an HTML element or when an HTML element’s value is copied into a model’s attribute, a function is called, this function is known as a converter in Backbone Js.

Q13. How are models attributes stored in Backbone.js?

Ans: In Backbone.js models attributes stored in a hash.

Q14. What is Router in Backbone? How do you create a Router with Backbone?

Ans: Backbone Router is used for routing client-side applications and connects them to actions and events using URLs. Backbone.Router is used to create a Router with Backbone.

Q15. How to Create a Model In Backbone js?

Ans: Creating a Model in Backbone Js
Person = Backbone.Model.extend({ initialize: function(){ alert("Welcome to Backbone Js"); } }); var person = new Person;

Q16. What is the function of toJSON?

Ans: toJSON is used for persistence, serialization and for augmentation before being sent to the server.

Q17. What Are “:params” And “*splats” In Dynamic Routing?
Backbone uses two styles of variables when implementing routes:

Ans:

  1. “:params” match any URL components between slashes. You can specify single fragment using “.params”
  2. “*splats” match any number of URL fragments after the query.
  3. Note that due to the nature of a “*splat”, it will always be the last variable in your URL as it will match any and all components.
  4. “*splats” or “:params” in route definitions are passed as arguments (in respective order) to the associated function.
  5. A route defined as “/:route/:action” will pass 2 variables (“route” and “action”) to the callback function.

Q18. What Is “el” Property Of Backbone.js View?

Ans: The “el” property references the DOM object created in the browser. Every Backbone.js view has an “el” property, and if it is not defined, Backbone.js will construct its own, which is an empty div element.

Q19. What Are The Configuration Options Available?

Ans: The configuration options available are:

  1. InitialCopyDirection
  2. modelSetOptions
  3. change Triggers
  4. boundAttribute
  5. suppressThrows
  6. converter

Q20. What is Collection in Backbone?

Ans: A collection is a set of models which binds events when the model has been modified in the collection. Collection contains a list of models that can be processed in the loop and supports sorting and filtering. When creating a collection, we can define what type of model that collection is going to have along with the instance of properties. Any event triggered on a model, which will also trigger on the collection in the model.

Q21. In a Backbone View, what is the use of setElement?

Ans: setElement function is used when Backbone view has to be applied to a different DOM element.

Topics:Backbone.js Interview QuestionsBackbone.js Interview Questions and AnswersInformation Technologies (IT)

Comments

Subscribe

Top Courses in Python

Top Courses in Python

We help you to choose the right Python career Path at myTectra. Here are the top courses in Python one can select. Learn More →

aathirai cut mango pickle

More...