JSFiddle - React, Tailwind, and code Playground

by ifandelse

JavaScript

function getAllPropertyNames( obj ) {

    function getAllProps( obj ) {
        return obj ? Object.getOwnPropertyNames( obj )
            .concat( getAllProps( Object.getPrototypeOf( obj ) )) : [];
    }

    function reduceFn( memo, cur, idx, arr ) {
        memo[ cur ] = true;
        return memo;
    }

    return Object.keys( getAllProps( obj ).reduce( reduceFn, {} )).sort();

}

$( "body" ).append( getAllPropertyNames( window ).join( "<br/>" ));