JavaScript: underscorejs with examples
In previous post I have mention about underscorejs library. And here is the another post to explain bit more about this library. Some functions used in below example to improve readability function prop(name){ return function(obj){ return obj[name]; } } function compareProp(prop, contextProp){ return function(obj){ return obj[prop] === this[contextProp]; } } Find visible user and show it’s default view Below is the list of JSON array with user object data. Now we want to show all visible user with it’s default view. var ar = [{ name: 'moe', age: 40, display: true, defaultView: 1, views: [ { name: 'Admin', id: 1 }, { name: 'Role1', id: 2 }, { name: 'Role2', id: 3 } ]},{ name: 'larry', age: 50, display: false, defaultView: 1, views: [ { name: 'Admin', id: 1 }, { name: 'Role1', id: 2 }, { name: 'Role2', id: 3 } ]},{ name: 'curly', age: 60, display: tr