如何在JAVASCRIPT中找到唯一的id值?现在我得到的只是价值.
I'm getting:-个
[
"Care One",
"Care Two"
"
I need:-个
[
{
"Source_ID": 1,
"SourceName_CR": "Care One"
},
{
"Source_ID": 2,
"SourceName_CR": "Care Two"
}
"
My code:-个
const body = [
{
Field_ID: 1,
FieldName_CR: "First Name",
Source_ID: 1,
SourceName_CR: "Care One"
},
{
Field_ID: 2,
FieldName_CR: "Last Name",
Source_ID: 1,
SourceName_CR: "Care One"
}, {
Field_ID: 3,
FieldName_CR: "Phone",
Source_ID: 2,
SourceName_CR: "Care Two"
},
{
Field_ID: 4,
FieldName_CR: "Email",
Source_ID: 2,
SourceName_CR: "Care Two"
}, ";
console.log([...new Set(body.map(item => item.SourceName_CR))");