JavaScript object literal length === undefined? August 5, 2023 by Tarik This is supported in node.js and newer environments. var obj = {a: "a", b: "b"}; Object.keys(obj).length // 2