Underscore Methods in Backbone.js

http://www.oop.it/?dissertation-statistical-services-transcription Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects.Underscore methods in backbone.js provides 80 different functions that support both the usual functional suspects, as well as more specialized helpers. It delegates to built-in functions, so modern browsers will use the native implementations of foreach, map, reduce, filter, every, some and indexof.
Collection Functions
There are 28 underscore functions under this caption. They join themselves with arrays and make the work much easier. We are going to discuss about them in the following few lines.collection functions work on arrays, objects, and array-like objects such as arguments, nodelist and similar. But it works by duck-typing. We should avoid passing objects with a numeric length property.

Academic Writing Reader Custom Package each:
We also know this function by the name of foreach.it Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is bound to the context object, if one is passed. Each invocation of iterator is called with three arguments: (element, index, list). If list is a JavaScript object, iterator’s arguments will be (value, key, list). Delegates to the native foreach function if it exists, and returns the original list for chaining.an each loop cannot be broken out of — to break, use _.find instead.

follow url _.each ([1, 2, 3], alert); => alerts each number in turn... _.each ({one: 1, two: 2, three: 3}, alert); => alerts each number value in turn.

how to write masters thesis map:
We also know this function by the name of collect.it produces a new array of values by mapping each value in list through a transformation function. If the native map method exists, it will be used instead. If list is a JavaScript object, iterator’s arguments will be (value, key, list).

http://yellowsubmarina.com/carters-typewriter-ribbon-and-carbon-paper-cabinet-box/ _.map ([1, 2, 3], function (num) {return num * 3 ;}); => [3, 6, and 9] _.map ({one: 1, two: 2, three: 3}, function (num, key) {return num * 3 ;}); => [3, 6, and 9]

home page reduce:
We also know this function by the name of inject.reduce boils down a list of values into a single value. Memo is the initial state of the reduction, and each successive step of it should be returned by iterator. The iterator is passed four arguments: the memo, then the value and index (or key) of the iteration, and finally a reference to the entire list.

http://www.bechburgmusikanten.ch/?master-thesis-ghostwriting var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0); => 6

maths studies coursework help reduceRight:
The right-associative version of reduce. Foldr is not as useful in JavaScript as it would be in a language with lazy evaluation.

essays on the scarlet letter var list = [[0, 1], [2, 3], [4, 5]]; var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); => [4, 5, 2, 3, 0, 1]

http://obatherbalbatuempedu.org/?p=a-level-design-and-technology-coursework-help find:
We also know this function by the name of detect.it Looks through each value in the list, returning the first one that passes a test or undefined if no value passes the test. The function returns as soon as it finds an acceptable element, and doesn’t traverse the entire list.

source link var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); => 2

go here filter:
Also known as select.Select Looks through each value in the list, returning an array of all the values that pass a test. Delegates to the native filter method, if it exists.

var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); => [2, 4, 6]

where:
Where Looks through each value in the list, returning an array of all the values that contain all of the key-value pairs listed in properties.

_.where(listOfPlays, {author: "Shakespeare", year: 1611});
=> [{title: "Cymbeline", author: "Shakespeare", year: 1611},
    {title: "The Tempest", author: "Shakespeare", year: 1611}]

reject:
Returns the values in list without the elements that the truth test (predicate) passes. The opposite of filter.

var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
=> [1, 3, 5]

every:
Also known as all. Every Returns true if all of the values in the list pass the test. Delegates to the native method every, if present.

_.every([true, 1, null, 'yes'], _.identity);
=> false

some:
Also known as any. Any Returns true if any of the values in the list pass the test. Short-circuits and stops traversing the list if a true element is found. Delegates to the native method some, if present.

_.some([null, 0, 'yes', false]);
=> true

contains:
We also know this function by the name of include. Include returns true if the value is present in the list. Uses indexof internally, if list is an array.

_.contains([1, 2, 3], 3);
=> true

Invoke:
Calls the method named by method name on each value in the list. Any extra arguments passed to invoke will be forwarded on to the method invocation.

_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
=> [[1, 5, 7], [1, 2, 3]]

pluck:
A convenient version of what is perhaps the most common use-case for map: extracting a list of property values.

var person = [{name: 'John', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
_.pluck(person, 'name');
=> ["moe", "larry", "curly"]

max:
It Returns the maximum value in list. If an iterator function is provided, it will be used on each value to generate the criterion by which the value is ranked.

var person = [{name: 'John', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
_.max(person, function(per){ return per.age; });
=> {name: 'curly', age: 60};

min:
It Returns the minimum value in list. If an iterator function is provided, it will be used on each value to generate the criterion by which the value is ranked.

var numbers = [10, 5, 100, 2, 1000];
_.min(numbers);
=> 2

sortBy:
Returns a sorted copy of list, ranked in ascending order by the results of running each value through iterator. Iterator may also be the string name of the property to sort by.

_.sortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); });
=> [5, 4, 6, 3, 1, 2]

indexBy:
Given a list, and an iterator function that returns a key for each element in the list (or a property name), returns an object with an index of each item. Just like groupby We can only use it when we are aware of the unique keys.

var person = [{name: 'John', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
_.indexBy(person, 'age');
=> {
  "50": {name: 'larry', age: 50},
  "60": {name: 'curly', age: 60}
}

countBy:
Sorts a list into groups and returns a count for the number of objects in each group. Similar to groupby, but instead of returning a list of values, returns a count for the number of values in that group.

_.countBy([1, 2, 3, 4, 5], function(num) {
  return num % 2 == 0 ? 'even': 'odd';
});
=> {odd: 3, even: 2}

shuffle:
Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle.

_.shuffle([1, 2, 3, 4, 5, 6]);
=> [4, 1, 6, 3, 5, 2]

sample:
Produce a random sample from the list. Pass a number to return n random elements from the list. Otherwise a single random item will be returned.

_.sample([1, 2, 3, 4, 5, 6]);
=> 4

toArray
Creates a real Array from the list. Useful for transmuting the arguments object.

(function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
=> [2, 3, 4]

size:
This function is used for deriving the size of the list.

_.size({one: 1, two: 2, three: 3});
=> 3

Some related articles :

1>Introduction to Backbone.js

2>Models in Backbone.js

3>Understanding view in Backbone.js

4>Collections in Backbone.js

5> Backbone Routes and History

6>Templates In Backbone.js

7>WHY SHOULD WE USE SERVER SIDE IN BACKBONE.JS?

8>Backbone.js at a glance

We will have other detail of Backbone features in our later articles. So please look for the same.
If you find this article helpful, you can connect us in  research paper on consumer behavior Google+ and http://ivkings.com/?q=custom-book-report  Twitter.