You can use _.filter, _.has, _.partial and _.negate methods, like this
console.log(_.filter(myArray, _.partial(_.negate(_.has), _, myDate)));
// [ { 'Wed May 24 2015 10:34:04 GMT+0000 (UTC)': 2.2 } ]
Here, _.negate(_.has) will return a new function which will just negate the result of _.has always.
_.partial(_.negate(_.has), _, myDate) will return a new function which will accept the values from myArray in the placeholder _ and _.has will be invoked with the value from the myArray and myDate as arguments.
_.has will return true if the object passed as the first argument has a key with the same name as the second parameter passed to it.
For older version of _
If you are using an older version of _, then you can simply pass a function object to do this,
console.log(_.filter(myArray, function(currentObject) {
return !_.has(currentObject, myDate);
}));
// [ { 'Wed May 24 2015 10:34:04 GMT+0000 (UTC)': 2.2 } ]
Vanila JS Version
console.log(myArray.filter(function(currenObject) {
return !currenObject.hasOwnProperty(myDate);
}));
// [ { 'Wed May 24 2015 10:34:04 GMT+0000 (UTC)': 2.2 } ]
You can simply use Array.prototype.filter function and check if the current object has a property with the value of myDate, with Object.prototype.hasOwnProperty.
If you are sure that the myDate will not have a value which will not be one of the inherited properties of Object, then you can also use in operator, like this
console.log(myArray.filter(function(currenObject) {
return !(myDate in currenObject);
}));
// [ { 'Wed May 24 2015 10:34:04 GMT+0000 (UTC)': 2.2 } ]
Datedata type is ISO 8601.new Date().toJSON()returns current date/time in ISO 8601. Butnew Date().toString()returns current date/time in human format like in your code snippets.