Answer the question
In order to leave comments, you need to log in
Redefine fields on an object?
Hello.
There is an object with fields
"BIRZHASP":[
{
"Code":"1",
"ForAbonentType":"ip"
},
{
"Code":"2",
"ForAbonentType":"ul"
}
],
"BIRZHASPF":[
{
"Code":"3",
"ForAbonentType":"ip"
},
{
"Code":"4",
"ForAbonentType":"ul"
}
],
[
{
serviceTypes: ['BIRZHASP', 'BIRZHASPF']
qualNames: {
ip: какой то код
ul: какой-то код
};
},
и так далее карточки с такими же данными
]
Answer the question
In order to leave comments, you need to log in
https://developer.mozilla.org/en/docs/Web/JavaScript...
let obj = {
"BIRZHASP":[
{
"Code":"1",
"ForAbonentType":"ip"
},
{
"Code":"2",
"ForAbonentType":"ul"
}
],
"BIRZHASPF":[
{
"Code":"3",
"ForAbonentType":"ip"
},
{
"Code":"4",
"ForAbonentType":"ul"
}
]
};
let arr = [
{
serviceTypes: ['BIRZHASP', 'BIRZHASPF']
qualNames: {
ip: какой то код
ul: какой-то код
};
}
];
arr.foreach(elem => {
elem.serviceTypes.forech(e => {
if (obj.hasOwnProperty(e)) {
elem.qualNames.ip = obj[e][0].ForAbonentType;
elem.qualNames.ul = obj[e][1].ForAbonentType;
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question