WordPress add inline JavaScript

This is the WordPress way to add inline JavaScript if you have no script dependencies:

wp_register_script( 'dummy-handle', '' );
wp_enqueue_script( 'dummy-handle' );
wp_add_inline_script( 'dummy-handle', 'var my_variable = true;', 'before' );