object number of keys javascript code example Example 1: js get number of keys in object Object.keys(obj).length Example 2: js count keys in object Object.keys(obj).length