filtered Data javascript

> data=[{date:'22-12-2014',name:'selva'},{date:'10-10-2010',name:'raja'},{date:'
11-11- 2011',name:'suresh'}]
[ { date: '22-12-2014', name: 'selva' },
  { date: '10-10-2010', name: 'raja' },
  { date: '11-11- 2011', name: 'suresh' } ]
> var filteredData  = []

> function parseDate(date){
... var date = date.split('-');
... var day = date[0]
... var month = date[1] - 1
... var year = date[2];
... return new Date(year, month, day)
... }

> for(var index in data){
... var obj = data[index];
... var date = parseDate(obj.date);
... if(date > new Date(2011, 0, 1))
... filteredData.push(obj)
... }


> filteredData
[ { date: '22-12-2014', name: 'selva' },
  { date: '11-11- 2011', name: 'suresh' } ]

No comments:

The Weekender: Moon metaphors, procrastinating monks, and a visit to a cheese factory

What we’re reading, watching, and listening to this week ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ...

Contact Form

Name

Email *

Message *