Get a default value of the Customizer setting using wp.customize API (JS)

It would make sense for the default value to be available via:

wp.customize.instance( 'slug_awesome_title' ).default

Or equivalently:

wp.customize( 'slug_awesome_title' ).default

However, I can see the default is simply not getting exported from PHP to JS. I can see that this is going to be needed in core also when client-side templating replaces server-side rendering of controls in #30738, so a core patch would be needed.

Nevertheless, in the mean time you can add the following PHP to export your default value onto the JS Setting object to have mostly the same effect:

add_action( 'customize_controls_enqueue_scripts', function() {
    global $wp_customize;
    wp_add_inline_script( 'customize-controls', sprintf(
        'wp.customize( "slug_awesome_title", function ( setting ) { setting.default = %s; } );',
        wp_json_encode( $wp_customize->get_setting( 'slug_awesome_title' )->default )
    ) );
} );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)