I am writing my code in NodeJS and have a object which looks as below.
const jsonData=
{
"description": "description",
"hosts": [
"host1",
"host2",
"host3"
]
}
I want to delete all host elements execpt the first one.
Desired Output:
const jsonData=
{
"description": "description",
"hosts": [
"host1"
]
}
And, the remaining elements should be moved to another variable.
const hostelementsExceptFirst = [ "host2", "host3" ];
I am performing the following operation but it is not giving desired output.
delete jsonData['hosts'];