Answers for "how to get the last key and value of an object at the same time in javascript"

2

las element of object

var fruitObject = { 'a' : 'apple', 'b' : 'banana', 'c' : 'carrot' };
Object.keys(fruitObject); // this returns all properties in an array ["a", "b", "c"]
fruitObject[Object.keys(fruitObject)[Object.keys(fruitObject).length - 1]] // "carrot"
Posted by: Guest on November-22-2020

Code answers related to "how to get the last key and value of an object at the same time in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language