[javascript] How to filter object array based on attributes?