To do this in any ES5-compatible environment , such as Node, Chrome, IE 9+, Firefox 4+, or Safari 5+:

Object.keys(obj).length