You have a JavaScript object consisting of keys and values pair, how do you get the total number of keys in a JavaScript object?
const person = {"name": "Pramana", "role": "Engineer", "province": "Bali"};
const count_keys = Object.keys(my_object).length;
console.log(count_keys);
Output
3
Notice that there are three keys inside our person
object, those are name
, role
, and province
.