The first one, ideally with a real link to follow in case the user has JavaScript disabled. Just make sure to return false to prevent the click event from firing if the JavaScript executes.
<a href="#" onclick="myJsFunc(); return false;">Link</a> If you use Angular2, this way works:
<a [routerLink]="" (click)="passTheSalt()">Click me</a>.
See here https://stackoverflow.com/a/45465728/2803344