You should use Require JS to add the JS, loading it via the XML is not best practice. This is because Require JS can track dependencies and only load scripts when required, instead of unnecessarily loading scripts and creating a maze of confusing dependencies.
To load JS via Require JS follow these steps:
Template:
In your template add:
<script type="text/x-magento-init">
{
// components initialized on the element defined by selector
"<element_selector>": {
"<js_component1>": ...,
"<js_component2>": ...
},
// components initialized without binding to an element
"*": {
"<js_component3>": ...
}
}
</script>
Where <js_component#>is the path to your JS, or alternatively the name of the module if you've mapped it with Require JS.
Script
Then write your JS inside Require like so:
<script>
require([
'jquery',
'anotherDependency'
], function ($) {
...
});
</script>
See http://devdocs.magento.com/guides/v2.1/javascript-dev-guide/javascript/js_init.html for more info.