Bagaimana membuat fungsi yang mengembalikan elemen di js

function elem(did) {
  return document.getElementById(did);
}
register_fm = elem('register_fm');
//---------------OR---------
function elem(did) {
  return document.querySelector(did);
}
register_fm = elem('#register_fm');
register_fm = elem('.register_fm');
register_fm = elem('p');
register_fm = elem('div');
Dan George