Skip to content

Instantly share code, notes, and snippets.

@foxbunny
Created June 9, 2025 02:46
Show Gist options
  • Select an option

  • Save foxbunny/3d462e563ccc4e4dc1c3f957d75ce4a4 to your computer and use it in GitHub Desktop.

Select an option

Save foxbunny/3d462e563ccc4e4dc1c3f957d75ce4a4 to your computer and use it in GitHub Desktop.
function findEnumerableProperties(obj) {
let enumerableProperties = []
let descriptors = Object.getOwnPropertyDescriptors(obj)
for (let k in descriptors)
if (descriptors[k].enumerable)
enumerableProperties.push(k)
return enumerableProperties
}
let builtins = [Object, Array, String, Number, Boolean, RegExp, Set, Map, Date, WeakMap, WeakSet, WeakRef, Function, Event, Element]
for (let ctor of builtins)
console.log(
ctor.name,
'prototype has',
findEnumerableProperties(ctor.prototype).length,
'enumerable properties'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment