For this purpose you can use wp_localize_cript()
function, like this:
function localize_my_script() {
$image_url = plugins_url( 'resources/images/myimage.png', __FILE__ );
$localizations = array( 'imageURL' => $image_url );
wp_localize_script( 'my-script-handle', 'localizedVars', $localizations );
}
add_action( 'wp_enqueue_scripts', 'localize_my_script' );
That is assuming that you have properly enqueued your script with my-script-handle
handle as an example.