I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object?
const myObject = new Object(); myObject["
What about something like this --
function keyValuePairs() { this.length = 0; function add(key, value) { this[key] = value; this.length++; } function remove(key) { if (this.hasOwnProperty(key)) { delete this[key]; this.length--; }} }