var arr = [
{0: {
count: 3,
emergency_count: 2,
object: {},
positions: {
0: {
position: "A-09-07B-11",
positionBarcode: "M01500",
wares: [{
0: {
action: null,
code: "9465",
data: "2018-03-31T00:00:00",
name: "Хлопья овс 400г экстра Русский завтрак",
}
}]
},
1: {
position: "A-09-07B-11",
positionBarcode: "M01500",
wares: [{
0: {
action: null,
code: "187853",
data: "2018-03-31T00:00:00",
name: "Мука в/с Алейка 1кг",
},
}]
},
},
}},
{1: {
count: 3,
emergency_count: 2,
object: {},
positions: {
0: {
position: "A-09-07B-11",
positionBarcode: "M01500",
wares: [{
0: {
action: null,
code: "127950",
data: "2018-03-31T00:00:00",
name: "Паста соево/перцовая Самдянг 500г контейнер",
}
}]
},
1: {
position: "A-06-02B-11",
positionBarcode: "M01007",
wares: [{
0: {
action: null,
code: "159859",
data: "2018-03-31T00:00:00",
name: "Чай Гринфилд Барберри вкус барбарис черн 25пак",
}
}]
},
},
}},
{2: {
count: 3,
emergency_count: 2,
object: {},
positions: {
0: {
position: "A-09-07B-11",
positionBarcode: "M01500",
wares: [{
0: {
action: null,
code: "383582",
data: "2018-03-31T00:00:00",
name: "Корнишоны маринов 540мл Середина лета",
},
}]
},
1: {
position: "A-06-02B-11",
positionBarcode: "M01007",
wares: [{
0: {
action: null,
code: "159859",
data: "2018-03-31T00:00:00",
name: "Чай Гринфилд Барберри вкус барбарис черн 25пак",
}
}]
},
}
}},
];
var code = "159859";
arr.find(
e=>Object.values(e).find(
e=>Object.values(e.positions).find(
e=>(p=e.position,e.wares.find(
e=>Object.values(e).find(
e=>e.code==code?n=e.name:0))))));
alert(n && 'name = ' + n + "\nposition = " + p || 'Not found');
var code = "159859";
var name;
var position;
var isBreak = false;
for (var arrProp in arr) {
for (var posProp in arrProperty.positions) {
for (var wares in posProp.wares) {
for (var waresProp in wares) {
if (waresProp.code ==code) {
name = waresProp.name;
position = posProp.position;
isBreak = true;
break;
}
}
if (isBreak) break;
}
if (isBreak) break;
}
if (isBreak) break;
}