Learn backbone.js tutorial from scratch for beginners(Part 20) Underscore js Methods in backbone.js

preview_player
Показать описание

1. _.each
Iterates over a list of elements, yielding each in turn to an iteratee function. The iteratee is bound
to the context object, if one is passed. Each invocation of iteratee is called with three arguments:
(element, index, list). If list is a JavaScript object, iteratee's arguments will be (value, key, list).
Returns the list for chaining.

2. _.where
_.where(list, properties)
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.
3. _.findWhere
_.findWhere(list, properties)
Looks through the list and returns the first value that matches all of the key-value pairs listed in properties.

4. _.find
_.find(list, predicate, [context])
Looks through each value in the list, returning the first one that passes a truth test (predicate), 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.

5. _.filter
_.filter(list, predicate, [context])
Looks through each value in the list, returning an array of all the values that pass a truth test (predicate).

6. _.pluck
_.pluck(list, propertyName)
A convenient version of what is perhaps the most common use-case for map: extracting a list of property values.

Here, look over the complete code

[script]

model: FModel
});

var player1 = new FModel({
name: "Ricky Ponting",
team: "Australia",
no: 1
});

var player2 = new FModel({
name: "Sachin",
team: "India",
no: 4
});

var player3 = new FModel({
name: "Chris Gayle",
team: "WestIndies",
no: 9
});

var fcollection = new FCollection();

collection: fcollection,
initialize: function () {
},
render: function () {
// _.each
});

//_.where

// _.findWhere

}
});


}
});


}
});

new FView();
[/script]


SOCIAL :
===============

Also you can learn Wordpress Custom
===============



Tags
===============
online web tutor,
profotech solutions,
backbone js for beginners,
backbone js tutorial for beginners in hindi,
backbone js tutorial for beginners with examples,
backbone js tutorial youtube,
backbone js tutorial video,
owt tuts,
online web tutorials,

Thanks
Online Web Tutor
Keep learning and Sharing :)
Рекомендации по теме
Комментарии
Автор

I can't make th e _.where, _.findWhere and _.pluck to work :( ... i use 1.10.2 underscore JS library

kimbarcelona
visit shbcf.ru