I have an object:
"languages": {
"en":["au", "uk"],
"de":["de"],
....
}
How can I remove everything but a specified key, so if I specify 'en' I just want an object that contains "en":["au", "uk"]
Simply, you could create a new object with specified field;
var key = 'en';
var o = {
"languages": {
"en": ["au", "uk"],
"de": ["de"]
}
}
var res = {}
res[key] = o.languages[key];