Duplicate Key to Only One

Run Settings
LanguageJavaScript
Language Version
Run Command
const data = [ { "id": 1, "claim_number": "#CL-20201022-0001", "transport_type": "self_transport", "claim_treatment": "money_exchange", "goods_treatment": "recognized", "dn_reference": "DN-VD20", "requested_by": "ADE APAD ALAMSYAH", "requested_phone": "081233444", "reason": "ff", "status": "executed", "customer_id": 4, "shop_id": 4, "total_qty": 6, "total_amount": "276354.00", "operator_name": "cek", "note": "AA", "is_approved": 1, "approved_at": "2020-10-22T09:08:18.000Z", "approved_by": "cek", "approval_remark": "ok", "created_at": "2020-10-22T02:06:50.000Z", "updated_at": "2020-10-22T02:56:28.000Z", "deleted_at": null }, { "id": 2, "claim_number": "#CL-20201023-0001", "transport_type": "self_transport", "claim_treatment": "goods_exchange", "goods_treatment": "recognized", "dn_reference": "#DN-20201023-0001", "requested_by": "ADE APAD ALAMSYAH", "requested_phone": "45454545", "reason": "Nyoba merge", "status": "waiting", "customer_id": 4, "shop_id": 4, "total_qty": 5, "total_amount": "274131.00", "operator_name": "cek", "note": null, "is_approved": 0, "approved_at": null, "approved_by": "", "approval_remark": "", "created_at": "2020-10-23T09:45:27.000Z", "updated_at": "2020-10-23T09:45:27.000Z", "deleted_at": null }, { "id": 3, "claim_number": "#CL-20201023-0002", "transport_type": "vendor_transport", "claim_treatment": "goods_exchange", "goods_treatment": "recognized", "dn_reference": "DN-VD21", "requested_by": "ACHMAD AFANDI", "requested_phone": "0987876", "reason": "ss", "status": "waiting", "customer_id": 3, "shop_id": 3, "total_qty": 6, "total_amount": "230040.00", "operator_name": "cek", "note": null, "is_approved": 0, "approved_at": null, "approved_by": "", "approval_remark": "", "created_at": "2020-10-23T10:47:57.000Z", "updated_at": "2020-10-23T10:47:58.000Z", "deleted_at": null }, { "id": 4, "claim_number": "#CL-20201023-0003", "transport_type": "self_transport", "claim_treatment": "goods_exchange", "goods_treatment": "recognized", "dn_reference": "#DN-20201023-0002", "requested_by": "AGUS NURWANTO", "requested_phone": "566777", "reason": "vv", "status": "waiting", "customer_id": 6, "shop_id": 6, "total_qty": 5, "total_amount": "350757.00", "operator_name": "cek", "note": null, "is_approved": 0, "approved_at": null, "approved_by": "", "approval_remark": "", "created_at": "2020-10-23T10:49:04.000Z", "updated_at": "2020-10-23T10:49:05.000Z", "deleted_at": null }, { "id": 5, "claim_number": "#CL-20201023-0004", "transport_type": "self_transport", "claim_treatment": "goods_exchange", "goods_treatment": "recognized", "dn_reference": "#DN-20201023-0003", "requested_by": "ADE APAD ALAMSYAH", "requested_phone": "67676767", "reason": "hhh", "status": "waiting", "customer_id": 4, "shop_id": 4, "total_qty": 2, "total_amount": "777265.50", "operator_name": "cek", "note": null, "is_approved": 0, "approved_at": null, "approved_by": "", "approval_remark": "", "created_at": "2020-10-23T10:57:28.000Z", "updated_at": "2020-10-23T10:57:28.000Z", "deleted_at": null } ] //Return Object let poolId = new Set(); data.forEach((a) => poolId.add(a.shop_id)); //Convert Object to Array let dataArray = [...poolId]; console.log(dataArray)
Editor Settings
Theme
Key bindings
Full width
Lines