Output all properties of object

Posted on
  • I noticed that the auto-completion tab in IDE is able to output more fields than a call to eg.:
    Object.getOwnPropertyNames(Bangle)
    Object.getOwnPropertyNames(Bangle.__prot­o__)

    Specifically, some object-like fields:
    Bangle.on
    Bangle.removeListener etc

    Similarly for a Promise object, I do not see the .then function as child object. How can I get full listing via javascript?

    The auto-complete is able to show all of these fields from a promise instance:

    >p.
    constructor         apply
    bind                call
    replaceWith         catch
    then                clone
    emit                hasOwnProperty
    length              on
    removeAllListeners  removeListener
    toString            valueOf
    

    How do I get these items into a javascript list?

  • There isn't a specific function available to JS (it's calling jswrap_object_keys_or_property_names_cb(­object, JSWOKPF_INCLUDE_NON_ENUMERABLE|JSWOKPF_I­NCLUDE_PROTOTYPE|JSWOKPF_NO_INCLUDE_ARRA­YBUFFER)

    But as I understand it you should be able to use Object.getOwnPropertyNames and then recursing down __proto__ of each object

  • I did try that recursion, I couldn't seem to get much results.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Output all properties of object

Posted by Avatar for d3nd3-o0 @d3nd3-o0

Actions