Exclude facets from flyout

<script>
/** 
 ** excludes facets from the flyout rather than having
 ** set array of facets to exclude to exclude_flyout
 ** to create an include list manually
 ** in facetwp/flyout/facets filter
 ** https://facetwp.com/help-center/add-on-features-and-extras/mobile-flyout/#customize-the-facets-and-facet-order
 **/

(function($) {
    $(function() {
        if ('object' != typeof FWP) return;
        FWP.hooks.addFilter('facetwp/flyout/facets', function(facets) {	
            const exclude_flyout = [ "search", "another_facet" ];   /* list facets to exclude as array */
            facets.forEach( function( item, index ) {
            if ( exclude_flyout.includes(item) ) {
                facets.splice( index, 1 );
            }
            });
            return facets;
        );
    });
})(jQuery);
</script>