Friday, 15 March 2019

BackboneJS


BackboneJS is a light weight JavaScript library that allows to develop and structure client side applications that run in a web browser. It offers MVC framework which abstracts data into models, DOM (Document Object Model) into views and bind these two using events. This tutorial covers most of the topics required for a basic understanding of BackboneJS and to get a feel of how it works.

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.


BackboneJS is a lightweight JavaScript library that allows to develop and structure the client side applications that run in a web browser. It offers MVC framework which abstracts data into models, DOM into views and bind these two using events.
History − BackboneJS was developed by Jeremy Ashkenas and was initially released on October 13th, 2010.
When to use Backbone
  • Consider you are creating an application with numerous lines of code using JavaScript or jQuery. In this application, if you −
    • add or replace DOM elements to the application or
    • make some requests or
    • show animation in the application or
    • add more number of lines to your code,
  • then your application might become complicated.
  • If you want a better design with less code, then it is better to use the BackboneJS library that provides good functionality, is well organized and in a structured manner for developing your application.
  • BackboneJS communicates via events; this ensures that you do not mess up the application. Your code will be cleaner, nicer and easy to maintain.
Features
The following are a list of features of BackboneJS −
  • BackboneJS allows developing of applications and the frontend in a much easier way by using JavaScript functions.
  • BackboneJS provides various building blocks such as models, views, events, routers and collections for assembling the client side web applications.
  • When a model changes, it automatically updates the HTML of your application.
  • BackboneJS is a simple library that helps in separating business and user interface logic.
  • It is free and open source library and contains over 100 available extensions.
  • It acts like a backbone for your project and helps to organize your code.
  • It manages the data model which includes the user data and displays that data at the server side with the same format written at the client side.
  • BackboneJS has a soft dependency with jQuery and a hard dependency with Underscore.js.

It allows to create client side web applications or mobile applications in a wellstructured and an organized format.

Sencha Extjs Array Utility classes

Folks,

Today we are going to discuss the basic and most important concept of Array utility methods.

Useful classes of Ext.Array

Ext.Array.erase(array, index, removeCount):


It will remove the item from an array

Removes items from an array. This is functionally equivalent to the splice method of Array, but works around bugs in IE8's splice method and does not copy the removed elements in order to return them (because very often they are ignored). 
It will returns array.

                // At index 0 erase 2 items.
     var a = Ext.Array.erase(['a', 'b', 'c', 'd', 'e'], 0, 2);  
     console.log(a); 
    // logs ["c", "d", "e"]
     

Ext.Array.unique(array)

Returns a new array with unique items.

               var a = [1, 2, 3, 4, 1, 2];
     var b = Ext.Array.unique(a);
     alert(b); // alerts [1, 2, 3, 4]


Ext.Array.merge(array1, array2, etc)

Merge multiple arrays into one with unique items.
union() is an alias for merge().

Ext.Array#union is an alias for Ext.Array#merge


               var a = [ 1, 2, 3 ];
     var b = [ 2, 3, 4 ];
     var c = [ 2, 3, 5 ];
     var d = [ 2, 3, 6 ];
     var e = Ext.Array.merge(a, b, c, d);
     alert(e); // alert [1, 2, 3, 4, 5, 6] - all items in a new array