That’s part of the default functionality available in wp_enqueue_script/wp_register_script.
The third argument, as seen in the official documentation of enqueue/register script, https://developer.wordpress.org/reference/functions/wp_enqueue_script/, https://developer.wordpress.org/reference/functions/wp_register_script/, is the dependencies array.
$deps string[] Optional
An array of registered script handles this script depends on.
Default: array()
So lets say you have script with the handle “sliderjs”, using your code it would look like this
function wpb_adding_scripts() {
wp_register_script('egovt-add-js', get_stylesheet_directory_uri() . '/add.js', ['sliderjs'],'1.1', true);
wp_enqueue_script('egovt-add-js');
}
add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );
// A multi line arguments example
/*
wp_register_script(
'egovt-add-js',
get_stylesheet_directory_uri() . '/add.js',
['sliderjs'], // <- this is the dependencies arrray
'1.1',
true
);
*/