#BAD!
$('.link').on('click', _ => $('.link').attr('href', $('.link').attr('href').replace(/#.+/,'')));
#GOOD!
const link = $('.link');
link.on('click', _ => link.attr('href', link.attr('href').replace(/#.+/, ''));
#BAD!
$('.link').on('click', _ => $('.link').attr('href', $('.link').attr('href').replace(/#.+/,'')));
#GOOD!
const link = $('.link');
link.on('click', _ => link.attr('href', link.attr('href').replace(/#.+/, ''));