Latest Questions

Post Top Ad

Your Ad Spot

Tuesday, June 25, 2019

25 Top Backbone.js Interview Questions and Answers {Updated}

Backbone.js Interview Questions and Answers for experienced PDF, Read commonly asked Backbone.js Job Interview Questions with Answers PDF for Freshers.


Read Backbone.js Interview Questions and Answers

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

What are the main components of Backbone.js?
The main component of Backbone.js is
  • Model
  • View
  • Collection
  • Router
  • Event class object

Explain what is Backbone.js collections?
An ordered set of models are represented by Backbone.js collections. Any event in the model will trigger an event in the collection directly.  For example, you can bind a “change” event to be notified in a case when any model in the collection has been modified.

What is Backbone.js router is used for?
Whenever an application wants to change its URL fragment in order to provide bookmarkable and shareable URLs for an Ajax heavy application, the backbone.js router is used.

What is Backbone events?
Backbone events is a module that can be mixed into 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 reflect the state of the model.

What are the key points of the Backbone ?
  • It has a 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 avoids you to embed HTML code inside JavaScript code
  • For UI updates and DOM manipulations if offers a significantly clean and elegant way

Why you have to use Backbone? Advantages?
  • 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
  • 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 JavaScript code mixing with HTML
  • Provides key-value binding and custom events
  • API with tons of functions
  • Robust event handling
  • API connection over a RESTful JSON interface

What are the three js files that you require to set up a working environment for the backbone?
you are required following three js files to set up 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

When you require Backbone.js?
Backbone.js is required in the 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

What is view in Backbone.js?
Backbone view is a Javascript object that manages a specific DOM element and descendants.
  • Views are not HTML
  • It is a description of a model
  • The HTML code comes from templates
  • Works with any template system

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.

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://www.babaquestions.com/* will serve /var/www/interviewquestionspdfs.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.

What is Modelbinder in Backbone.js?
To make the synchronization process of views and models together, the ModelBinder class is used.

What are the most powerful capabilities of the ModelBinder?
The most powerful capabilities of the 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 on the HTML “name” attribute.
  • You can define scoping with jQuery selectors if your views are complex.

What is Converter in Backbone.js?
A function is called when the 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 to as Converter in Backbone.js

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

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

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]

What are the configuration options available?
The configuration options available are
  • InitialCopyDirection
  • modelSetOptions
  • change Triggers
  • boundAttribute
  • suppressThrows
  • converter

What are the typical problems you might face with the Backbone view code?
  • Application models don’t change very often
  • Application pages are frequently refreshed from scratch from the server
  • Between the different view models are not shared

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

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 the server, in fetch.

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.

In Backbone View, what is the use of setElement?
the setElement function is used when a Backbone view has to be applied to a different DOM element.

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….

Post Top Ad

Your Ad Spot

Pages