JSFiddle - React, Tailwind, and code Playground
JavaScript
var object1 = [{
"value1": "1",
"value2": "2",
"value3": "3",
}, {
"value1": "1",
"value2": "5",
"value3": "7",
}, {
"value1": "6",
"value2": "9",
"value3": "5",
}, {
"value1": "6",
"value2": "9",
"value3": "5",
}];
var nbOcc = function (needle, haystack) {
return haystack.filter(function (record) {
return JSON.stringify(needle) === JSON.stringify(record);
}).length;
};
console.log(nbOcc({
"value1": "1",
"value2": "2",
"value3": "3",
}, object1)); // 1
console.log(nbOcc({
"value1": "6",
"value2": "9",
"value3": "5",
}, object1)); // 2