For modern enqueues, wp_add_inline_script with a script handle is cleaner than wp_localize_script. It does not require a global variable name.
For block editor data, use wp.data stores instead — they integrate with the editor’s reactivity and avoid the global-variable problem.
wp_localize_script remains correct for legacy enqueues that depend on jQuery and a global config object.