If you're just using a small script or other markup, you can hook a function to the wp_footer filter, which is included in all modern themes:
function wpse_77196_script_in_footer() {
<script language="javascript" type="text/javascript">
startcart()
</script>
}
add_filter( 'wp_footer', 'wpse_77196_script_in_footer' );
However, if your JavaScript code is more substantial, or you wish to use built-in libraries such as jQuery, you should put the code in an external file, enqueue it properly using the wp_enqueue_script() function:
wp_enqueue_script(
'myscript', // lowercase name of script
get_template_directory_uri() . '/js/script.js', // url to script
array( 'jquery' ), // libraries to use
false, // version of script (false is WP version)
true // load in footer (true) or head (false)?
);
You can read more about how to use the wp_enqueue_script() functon at the Codex
If you need more help, please post a comment below.