300+ TOP Backbone.js Interview Questions and Answers

Backbone.js Interview Questions for freshers experienced :-

1. What is backbone.js ?

Backbone.js is a JavaScript client-side (front end) framework, which helps to organize your code and makes it easier to develop single page applications. It allows you to structure JavaScript code in an MVC (Model, View , Controller) fashion

  • Model: It is a part of your code that populates and retrieves the data
  • View: It is the HTML representation of this model
  • Controller: It enables you to save your javascript application via a hashbang URl

2. What are the main components of Backbone.js ?

The main component of Backbone.js are

  • Model
  • View
  • Collection
  • Router
  • Event class object

3. What is Backbone.js collections ?

An ordered set of models are represented by Backbone.js collections. Any event in model will trigger 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.

4. What is Backbone.js router is used for ?

Whenever an application want to change their URL fragment in order to provide bookmarkable and shareable URLs for an Ajax heavy application, backbone.js router is used.

5. What is Backbone events ?

Backbone events is a module that can be mixed in to any object, giving the object the ability to bind and trigger custom named events. Events are not declared before they are bound to any object . Events reflects the state of the model.

6. What are the keypoints of Backbone ?

  • It has hard dependency with underscore.js to make it more functional and supporting a range of useful collection based operations
  • With jQuery it has a soft dependency
  • When the model changes it can update the HTML of your application automatically
  • It uses client-side rendering framework or Javascript templating to render html which avoid you to embed HTML code inside JavaScript code
  • For UI updates and DOM manipulations if offers a significantly clean and elegant way

7. Why you have to use Backbone ? Advantages ?

  1. By using JavaScript with the minimal set of data-structuring ( models & collections) and user interface (views & URLs) it enables you to develop a web application
  2. Backbone is best useful to develop MVC like web applications, single page web applications or complex JavaScript web applications in an organized and structured manner without
  3. JavaScript code mixing with HTML
  4. Provides key value binding and custom events
  5. API with tons of functions
  6. Robust event handling
  7. API connetion over a RESTful JSON interface

8. What are the three js files that you require to setup a working environment for backbone?

you are required following three js files to setup a working environment for backbone

  • jQuery
  • Backbone
  • Underscore

In your application put these files within js folder and use it in your index.html page

9. When you require Backbone.js ?

Backbone.js is required in following condition

  • When developing a web application that requires a lot of JavaScript
  • It is required when you want to give structure to your code, if your application needs to be scalable
  • Backbone is useful when a web application has to work with jQuery to traverse the DOM or give animations

10. What is view in Backbone.js?

Backbone view is a Javascript object that manages a specific DOM element and descendants.

  1. Views are not HTML
  2. It is a description of a model
  3. The HTML code comes from templates
  4. Works with any template system
Backbone.js Interview Questions
Backbone.js Interview Questions

11. What is Backbone.js Models?

Backbone.js models are object and core of backbone.js. It contains an array of attributes and listens for events. To represent your data, Backbone provides a model object. For example, you have a to do list, you would have a model representing each item on that list.

12. How you can use backbone.js for multiple page web app ?

For multiple page web app in backbone.js there are lots of consideration but here are two which can be useful

  • Serving the page : In this, where you want to have your web server route everything to the server route everything to serve the same static page. That means that everything in https://engineeringinterviewquestions.com/* will serve /var/www/engineeringinterviewquestions.com/index.html. once the static page is loaded, the JS on that page will decide what to do given the url
  • Push State : You can still use backbone routing to do your routing, but don’t use hashbangs. This will allow you to navigate to URLs without actually needing a page refresh.

13. What is Modelbinder in Backbone.js ?

To make synchronization process of views and models together, ModelBinder class is used.

14. What is the most powerful capabilities of the ModelBinder ?

The most powerful capabilities of ModelBinder class is that it enables you to define scope when you create your bindings using jQuery.

  • If your views are simple, you can rely on default scoping rules that are based off of the html “name” attribute.
  • You can define scoping with jQuery selectors if your views are complex.

15. What is Converter in Backbone.js ?

A function is called when model’s attribute is copied to an html element or when an html element value is copied into a model’s attribute, this function is referred as Converter in Backbone.js

16. 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. It is often a straightforward serialization of a row from the database

17. What is the function of toJSON ?

It returns a shallow copy of the model’s attribute for JSON stringification. This function is used for persistence, serialization and for augmentation before being sent to the server. This does not return a JSON string

18. When you can use Unbinding function in Backbone.js ?

When you want to remove the validation binding on the model or all models , removing all events hooked up on the collection, you can use Unbinding function.

For example : Backbone.Validation.Unbind(view) [ This will remove the validation binding]

19. What are the configuration options available ?

The configuration options available are

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

20. What are the typical problems you might face with the Backbone view code ?

  1. Application models don’t change very often
  2. Application pages are frequently refreshed from scratch from the server
  3. Between different view models are not shared

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 function of parse ?

Whenever a model’s data is returned by the server, in fetch and save , this data is called parse. It is called by Backbone whenever a collection’s models are returned by server, in fetch.

23. What is Backbone.sync is used for ?

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

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

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

25. What is model.cid ?

Model.cid works as a unique identifier. It is a special property of models, the cid or client id is automatically assigned to all models when they are first created. This property is useful when the model is not saved to the server, but needs to be visible in the UI. It takes the from c1,c2..

Backbone.js Questions and Answers Pdf Download

Leave a Reply

Your email address will not be published. Required fields are marked *