Enqueuing javascript files

Example for themes

I would recommend using wp_enqueue_script with get_theme_file_uri this allows child themes to overwrite this file.

get_theme_file_uri() function

Searches in the stylesheet directory before the template directory so
themes which inherit from a parent theme can just override one file.

wp_enqueue_script( 'example-script', get_theme_file_uri( '/js/example-script.js' ), array('jquery'), null, true );

Example for plugins

wp_enqueue_script( 'example-script', plugins_url('/js/example-script.js', __FILE__), array(), null );