True type de javascript

function trueTypeOf(element) {
  const regex = /\[object |[\]]/g;
  const prototypeString = Object.prototype.toString.call(element); // returns [object Type]

  return prototypeString.replace(regex, "");
}
Patrick Delaney