One thing you could do is set a variable in the archive.php like <script>var isArchive = true;</script>
. Or in any template do if (is_archive()) { /* set the variable */ }
.
And then in the JS file do if (typeof isArchive != 'undefined') { }
but there are probably way more elegant solutions that I’m unaware of.
This also probably assumes you load your scripts in the footer now that I think about it.
edit: of course you could also conditionally load your JS only on the archive pages and woudln’t need to test anything in the javascript itself.