javascript search json array for date
var startDate = new Date("2015-08-04");
var endDate = new Date("2015-08-12");
var resultProductData = product_data.filter(function (a) {
var hitDates = a.ProductHits || {};
// extract all date strings
hitDates = Object.keys(hitDates);
// improvement: use some. this is an improment because .map()
// and .filter() are walking through all elements.
// .some() stops this process if one item is found that returns true in the callback function and returns true for the whole expression
hitDateMatchExists = hitDates.some(function(dateStr) {
var date = new Date(dateStr);
return date >= startDate && date <= endDate
});
return hitDateMatchExists;
});
console.log(resultProductData);
Also in JavaScript:
- remove all mutliple items from array javascript
- how to reload webview in react native
- javascript array reorder elements
- javascript unknown number of parameters
- how to do a classname variable and string react
- ejs
- trim whitespace javascript
- javascript fetch json
- ejs include
- how to use labels in javascript
- how to use online mysql database with node js
- required false jquery
- button in vanilla js
- regex optional whitespace characters
- loop through json array python
- javascript empty function
- jquery cheat sheet
- javascript parse to string
- javascript dynamic arrays
- @editorjs/list window not defined
- replace json data python
- javascript variable object
- js split array into smaller arrays
- js array to json