In the code snippet below, I have a JavaScript object that I'm trying to add a similar object to using request.rules[0]
.
request : [
rules:
[
{
pageFilters:
[
{
matchType: 'contains',
type: 1,
value: 'a'
},
{
matchType: 'does not contain',
type: 1,
value: 'b'
}
],
name: 'TEST'
}
]
]
Here is the object I want to push into request.rules[1]:
{
pageFilters:
[
{
matchType: 'contains',
type: 1,
value: 'c'
},
{
matchType: 'does not contain',
type: 1,
value: 'd'
}
],
name: 'TEST 2'
}
Below is my attempted implementation, which is not working as expected...
request.rules[1].pageFilters[0].push({
matchType: 'contains',
type: 1,
value: 'c'
})
request.rules[1].pageFilters[1].push({
matchType: 'contains',
type: 1,
value: 'd'
})
request.rules[1].name = "TEST 2";
Here is the desired outcome:
request :[
rules:
[
{
pageFilters:
[
{
matchType: 'contains',
type: 1,
value: 'a'
},
{
matchType: 'does not contain',
type: 1,
value: 'b'
}
],
name: 'TEST'
},
{
pageFilters:
[
{
matchType: 'contains',
type: 1,
value: 'c'
},
{
matchType: 'does not contain',
type: 1,
value: 'd'
}
],
name: 'TEST 2'
}
]
]