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 6 New Rules of Communicating

The era of teleprompters and talking points has come to an end ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *