If I have an object like:
{ \'a\' : \'apple\', \'b\' : \'banana\', \'c\' : \'carrot\' }
If I don\'t know in advance that the list goes up
Solution using the destructuring assignment syntax of ES6:
var temp = { 'a' : 'apple', 'b' : 'banana', 'c' : 'carrot' }; var { [Object.keys(temp).pop()]: lastItem } = temp; console.info(lastItem); //"carrot"